8280124: Reduce branches decoding latin-1 chars from UTF-8 encoded bytes

Reviewed-by: rriggs, alanb, naoto
This commit is contained in:
Claes Redestad 2022-01-18 19:28:12 +00:00
parent bdfa15d92c
commit e314a4cfda
2 changed files with 105 additions and 46 deletions

View file

@ -541,8 +541,7 @@ public final class String
offset++;
continue;
}
if ((b1 == (byte)0xc2 || b1 == (byte)0xc3) &&
offset + 1 < sl) {
if ((b1 & 0xfe) == 0xc2 && offset + 1 < sl) { // b1 either 0xc2 or 0xc3
int b2 = bytes[offset + 1];
if (!isNotContinuation(b2)) {
dst[dp++] = (byte)decode2(b1, b2);
@ -698,8 +697,7 @@ public final class String
offset++;
continue;
}
if ((b1 == (byte) 0xc2 || b1 == (byte) 0xc3) &&
offset + 1 < sl) {
if ((b1 & 0xfe) == 0xc2 && offset + 1 < sl) { // b1 either 0xc2 or 0xc3
int b2 = bytes[offset + 1];
if (!isNotContinuation(b2)) {
dst[dp++] = (byte) decode2(b1, b2);