RFR: 8341566: Add Reader.of(CharSequence) [v11]

Markus KARG duke at openjdk.org
Tue Oct 15 10:46:17 UTC 2024


On Mon, 14 Oct 2024 20:01:42 GMT, Rob Spoor <duke at openjdk.org> wrote:

>> src/java.base/share/classes/java/io/Reader.java line 214:
>> 
>>> 212:                             cbuf[off + i] = cs.charAt(next + i);
>>> 213:                     }
>>> 214:                 }
>> 
>> Just a drive-by observation, not for this PR to handle:
>> 
>> If four out of five `CharSequence` implementations in the JDK include fast-path methods for copying char ranges into an output buffer, perhaps it is time to introduce `CharSequence::getChars` as a default method? 
>> 
>> That way, code like this wouldn't need to special-case for the known fast-paths, and external implementations could also join the party.
>
> That had been discussed here: https://github.com/openjdk/jdk/pull/21371#pullrequestreview-2350588453

Stay tuned. I have already forwarded a subsequent RFE and PR to cover this topic. 🤩

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21371#discussion_r1800909261


More information about the core-libs-dev mailing list