Am 11.08.2014 um 15:12 schrieb Andrej Golovnin:
In the most classes I mentioned in my previous mail only the
#toString()-methods would be affected by the proposal. And in the most
cases, maybe in all cases, the #toString()-methods in this classes exists
only to provide nice output.

So why not "nice input" from the java sources ...i.e.: use concatenation only if possible. The performance problem occurs, if both strategies are mixed.

Btw. I see here a nice opportunity to create an RFE
for the Javac team. Following code:

Object o1 = ...;
Object o2 = ...;
String s = "abc" + o1 + "c" + o2 + "\n";

should be translated to:

String s = new
StringBuilder().append("abc").append(o1).append('c').append(o2).append('\n').toString();

instead of:

String s = new
StringBuilder().append("abc").append(o1).append("c").append(o2).append("\n").toString();

+ manual .append("x") should be translated to .append("x")
+ Javac could avoid to instantiate multiple SBs from mixed concatenation/SB 
source code.
+ Javac could calculate a reasonable buffer size init value.

-Ulf

Reply via email to