On Fri, 19 Jul 2024 21:42:09 GMT, Shaojin Wen <d...@openjdk.org> wrote:

>> Currently simpleConcat is implemented using mix and prepend, but in this 
>> simple scenario, it can be implemented in a simpler way and can improve 
>> performance.
>
> 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 <li...@openjdk.org>
>  - add comments

This change seems reasonable, and we will need the `newArray(int)` method in 
future work. This patch dials back on the idea that `simpleConcat` is an 
"explainer" for what `StringConcatFactory` is doing, but as it was already 
imprecise in that regard we should favor simplicity and performance here.

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.

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

Marked as reviewed by redestad (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/20253#pullrequestreview-2193780530
PR Review Comment: https://git.openjdk.org/jdk/pull/20253#discussion_r1687937671

Reply via email to