On Tue, 23 Jul 2024 12:49:52 GMT, Shaojin Wen <d...@openjdk.org> wrote:

>> Yes, this isn't beholden to JLS 15.18.1, and it's already specified that 
>> `foo.concat("")` returns `foo` - so why shouldn't `"".concat(foo)` return 
>> `foo`? But still it's an observable semantic change so some care needs to be 
>> taken - possibly even a CSR is warranted. Doing `return new String(str)` to 
>> retain behavior avoids that headache for a fringe case.
>
> Adding isEmpty check is not related to this PR and should be a new PR.

Thanks. Removing this check will make the `"".append(foo)` edge case a little 
bit slower (likely inconsequential), but removes a branch and might thus even 
be an optimization in the common case.

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

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

Reply via email to