RFR: 8339704: Refactor StringConcatHelper simpleConcat [v2]
Claes Redestad
redestad at openjdk.org
Sun Sep 8 16:40:03 UTC 2024
On Sun, 8 Sep 2024 14:44:16 GMT, Shaojin Wen <swen at openjdk.org> wrote:
>> src/java.base/share/classes/java/lang/StringConcatHelper.java line 731:
>>
>>> 729: @ForceInline
>>> 730: static String concat(String prefix, float value, String suffix) {
>>> 731: if (prefix == null) prefix = "null";
>>
>> Since we'll never bind in `null` values all these `prefix == null` are likely redundant unless we expose them to users. Which we probably shouldn't. It's a good thing this PR actually removes some shared secrets rather than adding new ones.
>
> String concatenation is required in many places in java.lang. These static concat methods will be used instead of "+", so null value processing is added. This is also the motivation for using static concat methods instead of Concat1.
I don't think replacing a lot of concatenations in java.base with `SCH.concat` is very appealing and needs to be motivated by a substantial performance advantage. And for the places where it's motivated we can make sure to sanitize and handle `null` arguments.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20726#discussion_r1749288882
More information about the core-libs-dev
mailing list