RFR: 8325340: Add ASCII fast-path to Data-/ObjectInputStream.readUTF
Claes Redestad
redestad at openjdk.org
Tue Feb 13 16:13:12 UTC 2024
On Tue, 6 Feb 2024 18:40:20 GMT, Chen Liang <liach at openjdk.org> wrote:
>> Adding a fast-path for ASCII-only modified UTF-8 strings deserialied via Data- and ObjectInputStream
>>
>> Testing: tier1-3
>
> src/java.base/share/classes/java/io/ObjectInputStream.java line 3688:
>
>> 3686: // avoid a redundant scan
>> 3687: String utf = new String(buf, pos, (int)utflen, StandardCharsets.ISO_8859_1);
>> 3688: pos += (int)utflen;
>
> Suggestion:
>
> String utf = new String(buf, pos, ascii, StandardCharsets.ISO_8859_1);
> pos += ascii;
>
> Redundant casts
I get warnings and build failures if I leave out those casts (`utflen` is a `long`)
> src/java.base/share/classes/java/nio/charset/Charset.java line 682:
>
>> 680: else
>> 681: defaultCharset = sun.nio.cs.UTF_8.INSTANCE;
>> 682: Charset.forName("UTF-8");
>
> Redundant debug code?
Yes, accidentally included here.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/17734#discussion_r1480406485
PR Review Comment: https://git.openjdk.org/jdk/pull/17734#discussion_r1480404260
More information about the core-libs-dev
mailing list