RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v5]

Chen Liang liach at openjdk.org
Tue Jul 23 12:16:01 UTC 2024


On Tue, 23 Jul 2024 12:01:51 GMT, Claes Redestad <redestad at openjdk.org> wrote:

>> Shaojin Wen has updated the pull request incrementally with two additional commits since the last revision:
>> 
>>  - Update src/java.base/share/classes/java/lang/String.java
>>    
>>    Co-authored-by: Chen Liang <liach at openjdk.org>
>>  - add comments
>
> src/java.base/share/classes/java/lang/String.java line 2991:
> 
>> 2989:         }
>> 2990:         if (isEmpty()) {
>> 2991:             return str;
> 
> This case should probably be reflected more precisely in the specification, or do `return new String(str);` to avoid changing semantics for this corner-case.

The spec for concat only asked for equal representation instead of the existence of a new identity. Thus this should be fine.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20253#discussion_r1687954730


More information about the core-libs-dev mailing list