This is the mail archive of the java-patches@sourceware.cygnus.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: java patches for string concatonation


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]