mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 23:34:52 +02:00
8261744: Implement CharsetDecoder ASCII and latin-1 fast-paths
Reviewed-by: naoto, alanb
This commit is contained in:
parent
efbaedeb81
commit
433096a45e
13 changed files with 453 additions and 263 deletions
|
@ -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;
|
||||
|
|
|
@ -1981,6 +1981,11 @@ public final class System {
|
|||
* Initialize the system class. Called after thread initialization.
|
||||
*/
|
||||
private static void initPhase1() {
|
||||
|
||||
// register the shared secrets - do this first, since SystemProps.initProperties
|
||||
// might initialize CharsetDecoders that rely on it
|
||||
setJavaLangAccess();
|
||||
|
||||
// VM might invoke JNU_NewStringPlatform() to set those encoding
|
||||
// sensitive properties (user.home, user.name, boot.class.path, etc.)
|
||||
// during "props" initialization.
|
||||
|
@ -2026,8 +2031,6 @@ public final class System {
|
|||
Thread current = Thread.currentThread();
|
||||
current.getThreadGroup().add(current);
|
||||
|
||||
// register shared secrets
|
||||
setJavaLangAccess();
|
||||
|
||||
// Subsystems that are invoked during initialization can invoke
|
||||
// VM.isBooted() in order to avoid doing things that should
|
||||
|
@ -2277,6 +2280,14 @@ public final class System {
|
|||
return String.getBytesUTF8NoRepl(s);
|
||||
}
|
||||
|
||||
public void inflateBytesToChars(byte[] src, int srcOff, char[] dst, int dstOff, int len) {
|
||||
StringLatin1.inflate(src, srcOff, dst, dstOff, len);
|
||||
}
|
||||
|
||||
public int decodeASCII(byte[] src, int srcOff, char[] dst, int dstOff, int len) {
|
||||
return String.decodeASCII(src, srcOff, dst, dstOff, len);
|
||||
}
|
||||
|
||||
public void setCause(Throwable t, Throwable cause) {
|
||||
t.setCause(cause);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue