RFR: 8357289: Break down the String constructor into smaller methods [v3]

Claes Redestad redestad at openjdk.org
Mon May 26 12:14:52 UTC 2025


On Mon, 26 May 2025 12:00:02 GMT, Per Minborg <pminborg at openjdk.org> wrote:

>> I thought this would both increase cleaniness and reduce code size of the decode method. @minborg What do you think? This also removes one of the switches on COMPACT_STRING.
>
> I think it is better to keep the code smaller rather than saving 0.2 ns for skipping the zero-length check, which might get optimized away anyhow.

That zero-length check in `String(char[], int, int, Void)` was done as an optimization, too, so would be good if we leveraged it in paths that currently miss out for consistency. It was done maybe not so much for speed but to reduce memory and allocation pressure (empty `String`s are surprisingly common in many apps).

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25290#discussion_r2107206228


More information about the core-libs-dev mailing list