-
Enhancement
-
Resolution: Won't Fix
-
P4
-
None
-
None
The Slice.match method contains a loop, which checks if matching hit the end of the input on each iteration:
for (int j=0; j<len; j++) {
if ((i+j) >= matcher.to) {
matcher.hitEnd = true;
return false;
}
if (buf[j] != seq.charAt(i+j))
return false;
}
It would be more efficient to move this check out of the loop and do it only once.
for (int j=0; j<len; j++) {
if ((i+j) >= matcher.to) {
matcher.hitEnd = true;
return false;
}
if (buf[j] != seq.charAt(i+j))
return false;
}
It would be more efficient to move this check out of the loop and do it only once.