On Tue, 5 Jan 2021 18:10:52 GMT, Brian Burkhalter <b...@openjdk.org> wrote:

>> Philippe Marschall has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   Update copyright years
>
> src/java.base/share/classes/java/io/Reader.java line 198:
> 
>> 196:         } else {
>> 197:             int remaining = target.remaining();
>> 198:             char cbuf[] = new char[Math.min(remaining, 
>> TRANSFER_BUFFER_SIZE)];
> 
> As `cbuf` for the off-heap case is used in a synchronized block, is there the 
> opportunity for some sort of cached array here and would it help?

That would be possible. It would help in cases where a large Reader is read 
into one or several relatively small off-heap CharBuffers, requiring multiple 
#read calls. This can only be done when the caller is able to work with only a 
partial input. I don't know how common this case is.

We could re-purpose #skipBuffer, it has the same maximum size (8192) but 
determined by a different constant (#maxSkipBufferSize instead of 
#TRANSFER_BUFFER_SIZE). That would likely require it to be renamed and maybe we 
should even remove #maxSkipBufferSize. We could also do the reallocation and 
growing similar as is currently done in #skip.

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

PR: https://git.openjdk.java.net/jdk/pull/1915

Reply via email to