8261744: Implement CharsetDecoder ASCII and latin-1 fast-paths

Reviewed-by: naoto, alanb
This commit is contained in:
Claes Redestad 2021-02-19 15:05:25 +00:00
parent efbaedeb81
commit 433096a45e
13 changed files with 453 additions and 263 deletions

View file

@ -1008,6 +1008,27 @@ public final class String
//////////////////////////////// utf8 ////////////////////////////////////
/**
* Decodes ASCII from the source byte array into the destination
* char array. Used via JavaLangAccess from UTF_8 and other charset
* decoders.
*
* @return the number of bytes successfully decoded, at most len
*/
/* package-private */
static int decodeASCII(byte[] sa, int sp, char[] da, int dp, int len) {
if (!StringCoding.hasNegatives(sa, sp, len)) {
StringLatin1.inflate(sa, sp, da, dp, len);
return len;
} else {
int start = sp;
int end = sp + len;
while (sp < end && sa[sp] >= 0) {
da[dp++] = (char) sa[sp++];
}
return sp - start;
}
}
private static boolean isNotContinuation(int b) {
return (b & 0xc0) != 0x80;