Looks good. It’s tempting to do something like this to de-dup the code with less potential for mistakes:
String s = null; // Select the singular non-null value, if any If (s0 != null && s1 == null) s = s0; else if (s0 == null && s1 != null) s = s1; If (s != null) { if (s.isEmpty()) { … } else if (…) { … } } Paul. > On Jun 16, 2020, at 6:00 AM, Claes Redestad <claes.redes...@oracle.com> wrote: > > Hi, > > this patch specializes bootstrapping of unary concatenation expressions. > > Such expressions can be reduced to the canonical String.valueOf > "stringifier" for any primitive argument, but needs a special > stringifier for reference arguments since we need to produce a new > String to be compliant with JLS. > > Bug: https://bugs.openjdk.java.net/browse/JDK-8247681 > Webrev: http://cr.openjdk.java.net/~redestad/8247681/open.00/ > > This ensures we get a similar speed-up as JDK-8247605 for > "" + fooString (and fooString + ""). > > Also speeds up bootstrapping for all such simple unary concatenation > expressions. > > Testing: tier1+2 > > Before: > > Benchmark (intValue) Mode Cnt Score Error > Units > StringConcat.concatEmptyConstInt 4711 avgt 5 15.539 ± 0.831 > ns/op > StringConcat.concatEmptyConstString 4711 avgt 5 17.046 ± 1.047 > ns/op > StringConcat.concatEmptyLeft 4711 avgt 5 7.506 ± 0.588 > ns/op > StringConcat.concatEmptyRight 4711 avgt 5 7.890 ± 0.314 > ns/op > > After: > Benchmark (intValue) Mode Cnt Score Error > Units > StringConcat.concatEmptyConstInt 4711 avgt 5 15.410 ± 0.944 > ns/op > StringConcat.concatEmptyConstString 4711 avgt 5 7.397 ± 0.384 > ns/op > StringConcat.concatEmptyLeft 4711 avgt 5 7.465 ± 0.328 > ns/op > StringConcat.concatEmptyRight 4711 avgt 5 7.857 ± 0.355 > ns/op > > Thanks! > > /Claes