RFR (XS) 8060485: (str) contentEquals checks the String contents twice on mismatch
Aleksey Shipilev
aleksey.shipilev at oracle.com
Tue Oct 14 17:41:08 UTC 2014
On 14.10.2014 19:32, Stanimir Simeonoff wrote:
> Hi,
>
> This is an unrelated issue, yet is there any reason for the inner loop
> of equals to be written in such a (confusing) way?
>
> if (n == anotherString.value.length) {
> char v1[] = value;
> char v2[] = anotherString.value;
> int i = 0;
> while (n-- != 0) {
> if (v1[i] != v2[i])
> return false;
> i++;
> }
> return true;
> }
>
> instead of just "for (int i=0;i<n;i++) if (v1[i]!=v2[i]) return false;"
I think nobody just cares enough. Submit a patch for this?
The String.equals implementation is still intrinsified by C2 anyhow.
-Aleksey.
More information about the core-libs-dev
mailing list