< prev index next >

src/java.base/share/classes/sun/nio/cs/StandardCharsets.java.template

Print this page
8200310: Avoid charset lookup machinery in java.nio.charset.StandardCharsets
Reviewed-by: sherman

*** 81,93 **** private Map<String,Charset> cache() { Map<String,Charset> map = cache; if (map == null) { map = new Cache(); ! map.put("utf-8", UTF_8.INSTANCE); ! map.put("iso-8859-1", ISO_8859_1.INSTANCE); ! map.put("us-ascii", US_ASCII.INSTANCE); cache = map; } return map; } --- 81,96 ---- private Map<String,Charset> cache() { Map<String,Charset> map = cache; if (map == null) { map = new Cache(); ! map.put("utf-8", java.nio.charset.StandardCharsets.UTF_8); ! map.put("iso-8859-1", java.nio.charset.StandardCharsets.ISO_8859_1); ! map.put("us-ascii", java.nio.charset.StandardCharsets.US_ASCII); ! map.put("utf-16", java.nio.charset.StandardCharsets.UTF_16); ! map.put("utf-16be", java.nio.charset.StandardCharsets.UTF_16BE); ! map.put("utf-16le", java.nio.charset.StandardCharsets.UTF_16LE); cache = map; } return map; }
*** 121,135 **** // By checking these built-ins we can avoid initializing Aliases and // Classes eagerly during bootstrap String csn; if (charsetName.equals("UTF-8")) { ! return UTF_8.INSTANCE; } else if (charsetName.equals("US-ASCII")) { ! return US_ASCII.INSTANCE; } else if (charsetName.equals("ISO-8859-1")) { ! return ISO_8859_1.INSTANCE; } else { csn = canonicalize(toLower(charsetName)); } // Check cache first --- 124,138 ---- // By checking these built-ins we can avoid initializing Aliases and // Classes eagerly during bootstrap String csn; if (charsetName.equals("UTF-8")) { ! return java.nio.charset.StandardCharsets.UTF_8; } else if (charsetName.equals("US-ASCII")) { ! return java.nio.charset.StandardCharsets.US_ASCII; } else if (charsetName.equals("ISO-8859-1")) { ! return java.nio.charset.StandardCharsets.ISO_8859_1; } else { csn = canonicalize(toLower(charsetName)); } // Check cache first
< prev index next >