RFR: 8341566: Adding factory for non-synchronized CharSequence Reader [v3]
Chen Liang
liach at openjdk.org
Mon Oct 7 04:47:37 UTC 2024
On Sun, 6 Oct 2024 19:24:07 GMT, Brett Okken <duke at openjdk.org> wrote:
>> Markus KARG has updated the pull request incrementally with one additional commit since the last revision:
>>
>> fixup! Reader.of(String)
>>
>> Dropping non-public JavaDocs
>
> src/java.base/share/classes/java/io/Reader.java line 203:
>
>> 201: int n = Math.min(length - next, len);
>> 202: switch (cs) {
>> 203: case String s -> s.getChars(next, next + n, cbuf, off);
>
> There was some discussion on the mailing list of introducing a method to CharSequence for bulk getChars. Doing that would help both here and in Appendable/Writer implementations like StringWriter, PrintWriter, and OutputStreamWriter which currently convert to a String to then write.
>
> https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/io/Writer.java#L367
>
> https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/io/OutputStreamWriter.java#L253
I believe this batch operation would be a useful addition, but it is best reserved for another RFE.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21371#discussion_r1789479245
More information about the core-libs-dev
mailing list