Code (Pre-)Review for JEP 280: Indify String Concat

Andrej Golovnin andrej.golovnin at gmail.com
Fri Nov 27 07:47:25 UTC 2015


Hi Aleksey,

>   http://cr.openjdk.java.net/~shade/8085796/webrev.langtools.02/

test/tools/javac/T5024091/T5024091.java
src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/StringConcat.java

The files do not have the copyright header.

And I have one stupid question to com.sun.tools.javac.jvm.StringConcat:

The constants TAG_ARG and TAG_CONST are defined as Strings. From
performance standpoint of view, would it be not better to use char
instead of String?

I understand that:

if (a.contains(TAG_CONST) || a.contains(TAG_ARG))

is easier to read than:

if (a.indexOf(TAG_CONST) != -1 || a.indexOf(TAG_ARG) != -1)

But when you have a huge project to compile, maybe it can help to
reduce the compile time.


The line 330 in com.sun.tools.javac.jvm.StringConcat:

330                 recipe.append("null");

Maybe it is better to rewrite it as:

330                 recipe.append((String) null);

The first one requires to copy byte values from the "null" String. The
second one ends up in the call to AsbtractStringBuilder.appendNull().

Best regards,
Andrej Golovnin


More information about the compiler-dev mailing list