I found out that Java supports constant folding of primitive types , but what about Strings?
Example
If I create the following source code
out.write(""
+ "<markup>"
+ "<nested>"
+ "Easier to read if it is split into multiple lines"
+ "</nested>"
+ "</markup>"
+ "");
What is included in the compiled code?
The combined version? out.write("<markup><nested>Easier to read if it is split into multiple lines</nested></markup>");
Or a less efficient version of concatenation at runtime? out.write(new StringBuilder("").append("<markup>").append("<nested>").append("Easier to read if it is split into multiple lines").append("</nested>").append("</markup>").append(""));
source
share