8200310: Avoid charset lookup machinery in java.nio.charset.StandardCharsets

Reviewed-by: sherman, ulfzibis
This commit is contained in:
Martin Buchholz 2018-03-28 21:14:06 -07:00
parent 08adfe31b3
commit 4546512c19
11 changed files with 31 additions and 30 deletions

View file

@ -52,6 +52,9 @@ import static java.lang.Character.highSurrogate;
import static java.lang.Character.lowSurrogate;
import static java.lang.Character.isSupplementaryCodePoint;
import static java.lang.StringUTF16.putChar;
import static java.nio.charset.StandardCharsets.ISO_8859_1;
import static java.nio.charset.StandardCharsets.US_ASCII;
import static java.nio.charset.StandardCharsets.UTF_8;
/**
* Utility class for string encoding and decoding.
@ -67,10 +70,6 @@ class StringCoding {
private static final ThreadLocal<SoftReference<StringEncoder>> encoder =
new ThreadLocal<>();
private static final Charset ISO_8859_1 = sun.nio.cs.ISO_8859_1.INSTANCE;
private static final Charset US_ASCII = sun.nio.cs.US_ASCII.INSTANCE;
private static final Charset UTF_8 = sun.nio.cs.UTF_8.INSTANCE;
private static <T> T deref(ThreadLocal<SoftReference<T>> tl) {
SoftReference<T> sr = tl.get();
if (sr == null)