Replace concat String to append in StringBuilder parameters

Ulf Zibis Ulf.Zibis at CoSoCo.de
Mon Aug 11 00:59:08 UTC 2014


Am 11.08.2014 um 01:03 schrieb Claes Redestad:
> - in places like src/share/classes/sun/security/provider/PolicyFile.java
>   you end up with a sequence of String literal appends which could be merged into one:
>
> -                sb.append(principalInfo[i][0] + " " +
> -                    "\"" + principalInfo[i][1] + "\"");
> +                sb.append(principalInfo[i][0]).append(" \"")
> +                    .append(principalInfo[i][1]).append('"');

In cases of only 2 chars, I can imagine, that .append(' ').append('\"') would have better performance.

-Ulf




More information about the core-libs-dev mailing list