RFR 8193832: Performance of InputStream.readAllBytes() could be improved
Peter Levart
peter.levart at gmail.com
Wed Dec 20 23:47:02 UTC 2017
Hi Brian,
Brian Burkhalter je 20. 12. 2017 ob 22:54 napisal:
> Hi Peter,
>
> On Dec 20, 2017, at 3:45 AM, Peter Levart <peter.levart at gmail.com
> <mailto:peter.levart at gmail.com>> wrote:
>
>> if (result == null) {
>> result = copy;
>> } else {
>> bufs = new ArrayList<>(8); // <— ?
>> bufs.add(result);
>> bufs.add(copy);
>> }
>
> I am probably missing something here, but if the do-while loop
> iterates three or more times with nread > 0 each time won’t data be
> lost? Should this not instead be:
>
> if (result == null) {
> result = copy;
> } else {
> if (bufs == null) {
> bufs = new ArrayList<>(8);
> bufs.add(result);
> }
> bufs.add(copy);
> }
>
> Thanks,
>
> Brian
Yes, of course. Good catch. Next time I should try running the code
before proposing it...
webrev.03 looks good.
Regards, Peter
More information about the core-libs-dev
mailing list