
Signature
Steve W. Jackson
Montgomery, Alabama
On May 8, 10:56 am, "Steve W. Jackson" <stevewjack...@knology.net>
wrote:
> In article <1178642435.306145.301...@n59g2000hsh.googlegroups.com>,
>
[quoted text clipped - 12 lines]
> > I remember asking this question sometime a decade ago, do things
> > change:-?
> It's not a good idea to do this on any large scale in running code (as
> in concatenating literals to String variables, for instance) since it
> can cause performance and/or memory issues. That's why you have the
> StringBuilder and StringBuffer classes. But for compile-time literals,
> it shouldn't pose any problems.
The
String a += b + c;
part is routinely optimized to StringBuffer. (It is optimization bug
if it is not yet).
OK, on afterthought it seems to be merely a compiler issue. One must
have to redefine string literal in lexer rules.
Tom Hawtin - 08 May 2007 22:45 GMT
> String a += b + c;
You mean "a += b + c;" or "String a = b + c + d;"?
> part is routinely optimized to StringBuffer. (It is optimization bug
> if it is not yet).
Pessimised, actually. Assuming a, b and c really are String objects,
a = a.concat(b).concat(c);
is likely to be faster (from 1.5 at least).
Tom Hawtin