RFR: 8263038: Optimize String.format for simple specifiers

Claes Redestad redestad at openjdk.java.net
Mon Mar 8 12:13:07 UTC 2021


On Fri, 5 Mar 2021 17:08:28 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

>> I did think about it, but it seemed to stray a bit too far from the intent of this enhancement.
>
> I only looked at it because of the updates to use switch expressions...
> ok, either way.

I had reason to muck around with the switch expressions, since `Conversion.isValid` was inefficient (for startup) and subtly wrong (accepted `'t'`).

Getting rid of explicit unboxing - `.byteValue()` - is just a syntactic improvement, so I indulged in a few places.

Using instanceof pattern matching OTOH changes bytecode shape a fair bit by introducing locals and changing the execution order. The suggestions you made above also mean we'd unbox twice. Probably inconsequential, but I'm wary of such changes when I don't have benchmarks to assert they are performance neutral.

-------------

PR: https://git.openjdk.java.net/jdk/pull/2830


More information about the core-libs-dev mailing list