On Sun, 8 Sep 2024 07:52:26 GMT, Shaojin Wen <[email protected]> wrote:
> Similar to ObjectInputStream, use JLA.countPositives and
> JLA.inflateBytesToChars to speed up readUTF
Thanks for the logical cleanup. I will find another io reviewer too.
Another comment: we currently eagerly allocate a char array, but now we can
choose to only allocate the char array if we have non-ascii.
src/java.base/share/classes/java/io/DataInputStream.java line 590:
> 588: if (bytearr == null) {
> 589: bytearr = new byte[utflen];
> 590: allocate = true;
Can we rename this boolean to `trusted` and set it to `false` when we assign it
back to `dis.bytearr`? Even though that assignment will be redundant, calling
it `trusted` is helpful to avoid causing security problems if we reorganize
this code in the future.
src/java.base/share/classes/java/io/DataInputStream.java line 609:
> 607: }
> 608: if (allocate && in instanceof DataInputStream dis) {
> 609: dis.bytearr = bytearr;
Continuing last comment: after rename to `trusted`, add something like `trusted
= false` here.
-------------
Marked as reviewed by liach (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/20903#pullrequestreview-2308109688
PR Comment: https://git.openjdk.org/jdk/pull/20903#issuecomment-2336657443
PR Review Comment: https://git.openjdk.org/jdk/pull/20903#discussion_r1761126286
PR Review Comment: https://git.openjdk.org/jdk/pull/20903#discussion_r1761127156