[kaffe] Slow byte to char conversion
Godmar Back
kaffe@rufus.w3.org
Mon, 28 Aug 2000 09:19:04 -0600 (MDT)
>
>
> Godmar Back wrote:
>
> [...] Every call results in a new
> > converter object being newinstanced, just to convert a bunch of bytes.
> > (The new converter was one of the changes done to make the
> > charset conversion thread-safe.)
> [...]
>
> And why exactly default converter could not be cached and same instance
> used for all conversions ? I think it is stateless class, so it should
> be safe to enter same object method from various threads with all state
> on stack.
>
It is not stateless; it keeps track of not converted characters/bytes
if there are any left. See the carry/flush methods.
The converter only converts 512 bytes at a time (see String.decodeBytes).
Now just why the converter does that, I don't know. It's not immediately
apparent what the motivation for that is, if there is any.
Plus, I don't understand why the encoder doesn't directly convert into
the StringBuffer that is going to be returned by decodeBytes.
It all seems rather strange, and as always there's no comments in the code.
- Godmar