RFR: 8340232: Optimize DataInputStream::readUTF
ExE Boss
duke at openjdk.org
Tue Sep 17 03:29:31 UTC 2024
On Sun, 8 Sep 2024 07:52:26 GMT, Shaojin Wen <swen at 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);
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20903#discussion_r1749167163
More information about the core-libs-dev
mailing list