8268813: Better String matching

Reviewed-by: mschoene, rhalade, smarks
This commit is contained in:
Ian Graves 2021-09-02 19:20:30 +00:00 committed by Henry Jen
parent 4be02d3155
commit aa28430bdd

View file

@ -3438,8 +3438,8 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
private static final int countChars(CharSequence seq, int index,
int lengthInCodePoints) {
// optimization
if (lengthInCodePoints == 1 && !Character.isHighSurrogate(seq.charAt(index))) {
assert (index >= 0 && index < seq.length());
if (lengthInCodePoints == 1 && index >= 0 && index < seq.length() &&
!Character.isHighSurrogate(seq.charAt(index))) {
return 1;
}
int length = seq.length();