Re:A Million Lines of Bad Code
by jmgao on Friday April 17, 2015 @05:02PM
(#9397184)
This is true, javac only replaces individual concatentations with use of a StringBuilder, so foo + bar + baz + "!" is fast, but performing a concatenation in a loop does multiple copies for each iteration. It (or the JIT) could conceivably do escape analysis to optimize simple cases like this, but it doesn't.
builder: http://hastebin.com/qadusoriqa.cs
concat: http://hastebin.com/nasukuxemi.cs