java patches for string concatonation
Jeff Sturm
jsturm@sigma6.com
Sun Jan 9 18:12:00 GMT 2000
Tom Tromey wrote:
> Eventually I think we should stop using StringBuffer to implement
> string concatenation, and instead use something faster. For example,
> we could use a StringBuffer-like class (that would also be used by the
> StringBuffer implementation) which does not have any synchronization.
For native compilation, I agree. However, using anything but
StringBuffer would jeopardize compatibility in the bytecode compiler.
So if this optimization is done at the tree level it may have to be
switched off for bytecode generation.
Another possible way to improve string concatenation is to have the
compiler guess at the eventual buffer size, or a reasonable upper bound,
rather than allocating 16 bytes by default.
> We could even allocate the buffer on the stack in some siuations, or
> perhaps partially allocate it on the stack (and revert to the heap on
> overflow).
Stack allocation is an interesting idea but perhaps not so useful for
string concatenation... in many cases the stack buffer would have to be
copied to permanent heap storage when constructing the String object.
--
Jeff Sturm
jsturm@sigma6.com
More information about the Java-patches
mailing list