RFR 8193832: Performance of InputStream.readAllBytes() could be improved

Brian Burkhalter brian.burkhalter at oracle.com
Tue Dec 19 22:36:32 UTC 2017

On Dec 19, 2017, at 2:28 PM, Paul Sandoz <paul.sandoz at oracle.com> wrote:

>> Done. Updated: http://cr.openjdk.java.net/~bpb/8193832/webrev.01/
> You can also simplify the “for(;;) + break" into a do while loop:
> do {
>   int nread = 0;
>   ...
> } while (n > 0);

Good suggestion but I think that this needs to be "while (n >= 0)."

>> Good suggestions! Not sure however about line 237 as with var it has to be “var n = 0;” instead of simply “int n;” with no initialization.
> I was only suggesting it’s use for the byte[] and ArrayList<byte[]>. IMHO it’s a little subjective but there is less upside for int, although one can argue consistent application and explicit initialization is a good thing here.

I had left the ints as ints in an intermediate copy before Remi’s message. I also prefer to leave them as ints.


More information about the core-libs-dev mailing list