RFR: 4926314: Optimize Reader.read(CharBuffer) [v9]
Brian Burkhalter
bpb at openjdk.java.net
Fri Apr 16 17:24:44 UTC 2021
On Sat, 13 Mar 2021 14:28:25 GMT, Philippe Marschall <github.com+471021+marschall at openjdk.org> wrote:
>> Implement three optimiztations for Reader.read(CharBuffer)
>>
>> * Add a code path for heap buffers in Reader#read to use the backing array instead of allocating a new one.
>> * Change the code path for direct buffers in Reader#read to limit the intermediate allocation to `TRANSFER_BUFFER_SIZE`.
>> * Implement `InputStreamReader#read(CharBuffer)` and delegate to `StreamDecoder`.
>> * Implement `StreamDecoder#read(CharBuffer)` and avoid buffer allocation.
>
> Philippe Marschall has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 15 commits:
>
> - Merge master
> - Fix bug in CharArrayReader and add unit test
> - Clean up unit tests
> - Revert off-heap code path
> - Replace c-style array declarations
> - Share work buffer between #skip and #read
> - Update copyright year
> - Implement review comment
> - Revert StreamDecoder changes
> - Implement CharArrayReader#read(CharBuffer)
> - ... and 5 more: https://git.openjdk.java.net/jdk/compare/d339320e...c4c859e0
test/jdk/java/io/Reader/ReadCharBuffer.java line 83:
> 81: buffer.limit(8 + 8192 + 1);
> 82: buffer.position(8);
> 83: assertEquals(reader.read(buffer), 8192 + 1);
Lines 80 + 83 might be easier to read if replaced with
int position = 8;
limit = position + 8192 + 1;
buffer.limit(limit);
buffer.position(position);
assertEquals(reader.read(buffer), limit - position);
-------------
PR: https://git.openjdk.java.net/jdk/pull/1915
More information about the core-libs-dev
mailing list