On Sun, 3 Dec 2023 06:05:45 GMT, Francesco Nigro <[email protected]> wrote:
>> src/java.base/share/classes/java/lang/String.java line 2184:
>>
>>> 2182: byte[] tv = value;
>>> 2183: byte[] ov = other.value;
>>> 2184: if (coder == otherCoder) {
>>
>> Is this change needed as `otherCoder` is not reused?
>>
>> Suggestion:
>>
>> byte[] tv = value;
>> byte[] ov = other.value;
>> byte coder = coder();
>> if (coder == other.coder()) {
>
> Not necessary, but given that later, in the path I have introduced, I am
> using directly the coder byte to both compute the actual length of `tv`
> (inlining String::length) and verify the coder to be the same for both `tv`
> and `ov`, I have avoided fetching it twice.
> I see that "could" increase the register pressure, but I haven't verified it
> yet; there is any performance concern or is a readability/style-only concern?
Defer to the maintainers on preference, I just noticed `otherCoder` was unused
outside of single comparison and other similar patterns in this file seem to
inline.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16933#discussion_r1413875411