RFR: 8325340: Add ASCII fast-path to Data-/ObjectInputStream.readUTF

Chen Liang liach at openjdk.org
Tue Feb 13 16:13:12 UTC 2024


On Tue, 6 Feb 2024 18:58:01 GMT, Claes Redestad <redestad at openjdk.org> wrote:

>> 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`)

Ah, I meant to use the equivalent local variable int ascii, the return value of countPositives, to avoid these casts.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/17734#discussion_r1480639568


More information about the nio-dev mailing list