RFR 8214971 : Replace use of string.equals("") with isEmpty()

Claes Redestad claes.redestad at oracle.com
Fri Dec 7 19:35:18 UTC 2018

This is an interesting point: can anyone explain why there are two 
distinct methods for LATIN1 and UTF16 equality, with corresponding
intrinsics? Aleksey? Tobias?

Testing with Arrays.equals then performance profile is
quite different due vectorization (often better, sometimes worse),
but this is performance-neutral for a variety of latin1 and utf16 inputs:

if (coder() == aString.coder())
     return StringLatin1.equals(value, aString.value);

Is there some UTF16 input where StringLatin1.equals != 
StringUTF16.equals that forbids the above? Performance-wise it seems 
neutral, and all tests seem to pass with the above (obviously need to 
run more tests...).



On 2018-12-07 04:53, James Laskey wrote:
> Or simply;
> if (anObject instanceof String) {
>             String aString = (String)anObject;
>             if (coder() == aString.coder())
>                  return Arrays.equals(value, aString.value);
>             }
>         }
> Sent from my iPhone

More information about the core-libs-dev mailing list