8325169: Reduce String::indexOf overheads

Reviewed-by: rriggs, rgiulietti, mli
This commit is contained in:
Claes Redestad 2024-02-05 16:30:05 +00:00
parent 89e6a02e3b
commit 19e92201b4
4 changed files with 23 additions and 19 deletions

View file

@ -310,15 +310,11 @@ final class StringLatin1 {
};
}
// Caller must ensure that from- and toIndex are within bounds
public static int indexOf(byte[] value, int ch, int fromIndex, int toIndex) {
if (!canEncode(ch)) {
return -1;
}
fromIndex = Math.max(fromIndex, 0);
toIndex = Math.min(toIndex, value.length);
if (fromIndex >= toIndex) {
return -1;
}
return indexOfChar(value, ch, fromIndex, toIndex);
}