On Sun, 10 Jan 2021 01:59:18 GMT, Brett Okken 
<github.com+2996845+bok...@openjdk.org> wrote:

>> Philippe Marschall has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   Add unit tests
>>   
>>   - add unit test for Reader#read(CharBuffer)
>>   - add unit test for InputStreamReader#reader(CharBuffer)
>>   - test with both on-heap and off-heap buffers
>
> 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)];
> 
> Would there be value in making this a (lazily created) member variable? That 
> would allow a single instance to be reused. It seems likely that, if one call 
> is made with a direct CharBuffer, subsequent calls will also be made with 
> direct instances (probably same instance?).

I am not sure. It would help to reduce the allocation rate when reading a large 
amount of data into a small direct CharBuffer. I don't know how common that is. 
We would introduce an instance variable for one path in one method.

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

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

Reply via email to