RFR: 8343110: Add getChars(int, int, char[], int) to CharSequence and CharBuffer

Markus KARG duke at openjdk.org
Tue Mar 25 12:09:21 UTC 2025


On Sun, 23 Mar 2025 08:42:55 GMT, Chen Liang <liach at openjdk.org> wrote:

>> This Pull Request proposes an implementation for [JDK-8343110](https://bugs.openjdk.org/browse/JDK-8343110): Adding the new method `public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)` to the `CharSequence` interface, providing a **bulk-read** facility including a default implementation iterating over `charAt(int)`.
>> 
>> In addition, this Pull Request proposes to replace the implementation of `Reader.of(CharSequence).read(char[] cbuf, int off, int len)` to invoke `CharSequence.getChars(next, next + n, cbuf, off)` instead of utilizing pattern matching for switch. Also, this PR proposes to implement `CharBuffer.getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)` as an alias for `CharBuffer.get(srcBegin, dst, dstBegin, srcEnd - srcBegin)`.
>> 
>> To ensure quality...
>> * ...the method signature and JavaDocs are adapted from `AbstractStringBuilder.getChars(...)`.
>> * ...this PR relies upon the existing tests for `Reader.of(CharSequence)`, as these provide sufficient coverage of all changes introduced by this PR.
>
> Oops sorry, did a round of review but forgot to finish it :(

@liach I fixed all your requested changes. Would you please be so kind and mark this PR as reviewed? I will then go on with the CSR.

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

PR Comment: https://git.openjdk.org/jdk/pull/21730#issuecomment-2751041582


More information about the nio-dev mailing list