Hello!
I read source code equalsIgnoreCase(...) in String class and saw that it is not optimal. This method check length and call regionMatches(...) with 'constant' values
...
&& (anotherString.value.length == value.length)
&& regionMatches(true, 0, anotherString, 0, value.length);
...
But regionMatches(...) check 'constant' values
// Note: toffset, ooffset, or len might be near -1>>>1.
if ((ooffset < 0) || (toffset < 0)
|| (toffset > (long)value.length - len)
|| (ooffset > (long)other.value.length - len)) {
return false;
}
and increment equalent variables to==po in loop
while (len-- > 0) {
char c1 = ta[to++];
char c2 = pa[po++];
...
}
and use if(...) in while loop
if (ignoreCase) {
...
}
May be can create optimized regionMatches(...) for use in equalsIgnoreCase(...)?