This is the mail archive of the
java-patches@sourceware.cygnus.com
mailing list for the Java project.
Re: java patches for string concatonation
- To: Anthony Green <green at cygnus dot com>
- Subject: Re: java patches for string concatonation
- From: Tom Tromey <tromey at cygnus dot com>
- Date: Sun, 9 Jan 2000 17:13:20 -0800 (PST)
- Cc: java-patches at sourceware dot cygnus dot com, gcc-patches at gcc dot gnu dot org
- References: <200001092259.OAA18286@hoser.cygnus.com>
Anthony> When gcj sees string concatonation with the "+" operator, and
Anthony> the first operand (op1) is either a String reference or a
Anthony> string literal, we emit a call to `new StringBuffer(op1)' and
Anthony> append op2. If op1 is null then this constructor should be
Anthony> throwing a NullPointerException, however, right now it is
Anthony> filling the buffer with "null".
The libgcj side is fine provided that the compiler side goes in too.
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.
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).
Tom