[kaffe] Slow byte to char conversion

Artur Biesiadowski abies at pg.gda.pl
Mon Aug 28 12:12:33 PDT 2000

Godmar Back wrote:

> 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.

I've looked at this and I don't see a reason for CharToByteConverter to
go through encode/flush stes - it would work perfectly all right with
single step method, returning new byte[] for example. For
ByteToCharConverter things are a bit different, as streams can stop
inside multibyte encoding. It could be workaround by changing interface
a bit and allowing converter to ruteurn number of rejected bytes, which
would have to be fed to it again on next call. This moves need to
remember state to OutputStreamWriter and it is ok as it will
synchronized itself.

I'm going to look how it was solved in classpath (I suppose they have
still almost 2 years old bug with static variables, but thats not
important:), maybe some ideas could be scavenged.


More information about the kaffe mailing list