RFR: 8340232: Optimize DataInputStream::readUTF
Chen Liang
liach at openjdk.org
Tue Sep 17 03:29:31 UTC 2024
On Sun, 8 Sep 2024 10:05:35 GMT, ExE Boss <duke 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);
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
More information about the core-libs-dev
mailing list