#8 Buf

brian Fri 9 Dec 2005

We talked about trying to create a single Buf class which would serve as both a StringBuffer and byte[] role to handle mutable sequences of bytes/characters. Ideally we would just always store things in a byte[] internally, then use a specified character encoding when converting to a Str. However there seems to a huge difference in performance between String(char[]) and String(byte[], String) - at least on the Java side. So I'm not sure how we implement efficiently, since the two main use cases will both be heavily used. But I think having a consistent model for Buf, InStream, and OutStream will be very useful and is an overriding design goal. I'm thinking that maybe under the covers based on the "encoding" that we switch to an internal helper class that uses byte[] or char[] natively. We will need to give some more thoughts how to make this work via a clean API.

Login or Signup to reply.