RFR: 8343110: Add getChars(int, int, char[], int) to CharSequence and CharBuffer [v11]
Chen Liang
liach at openjdk.org
Thu May 1 12:59:51 UTC 2025
On Thu, 1 May 2025 08:45:06 GMT, Markus KARG <duke 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.
>
> Markus KARG has updated the pull request incrementally with one additional commit since the last revision:
>
> Applied proposal by Daniel: If there's no change to this file the copyright year update could be reverted?
src/java.base/share/classes/java/lang/AbstractStringBuilder.java line 488:
> 486: /**
> 487: * {@inheritDoc CharSequence}
> 488: */
Suggestion:
* {@inheritDoc CharSequence}
* @param srcBegin {@inheritDoc CharSequence}
* @param srcEnd {@inheritDoc CharSequence}
* @param dst {@inheritDoc CharSequence}
* @param dstBegin {@inheritDoc CharSequence}
* @throws IndexOutOfBoundsException {@inheritDoc CharSequence}
*/
Let's aim for text parity for now; can you create a bug for Javadoc for this inheritDoc inconsistency?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21730#discussion_r2070240781
More information about the core-libs-dev
mailing list