On Sun, 8 Sep 2024 10:05:35 GMT, ExE Boss <d...@openjdk.org> wrote: >> Similar to ObjectInputStream, use JLA.countPositives and >> JLA.inflateBytesToChars to speed up readUTF > > src/java.base/share/classes/java/io/DataInputStream.java line 602: > >> 600: int ascii = JLA.countPositives(bytearr, 0, utflen); >> 601: if (ascii == utflen) { >> 602: return new String(bytearr, 0, utflen, >> StandardCharsets.ISO_8859_1); > > Maybe use `sun.nio.cs.ISO_8859_1.INSTANCE` instead in order to avoid > initialising unused charsets: > Suggestion: > > return new String(bytearr, 0, utflen, ISO_8859_1.INSTANCE);
We should use `StandardCharsets` as in most other standard usages. This method is not on bootstrap path, so readability is more important. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/20903#discussion_r1749203988