RFR: 8341566: Adding factory for non-synchronized CharSequence Reader [v3]

Markus KARG duke at openjdk.org
Tue Oct 8 11:29:04 UTC 2024


On Mon, 7 Oct 2024 04:43:49 GMT, Chen Liang <liach at openjdk.org> wrote:

>> 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.

Agree to Chen. As I already wrote in [the RFE](https://bugs.openjdk.org/browse/JDK-8341566):
>As this option is not essentially needed, and as it implies deeper thought and discussion, this option is explicitly EXCLUDED from this current enhancement request. We can pick it up later in a subsequent enhancement request.

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

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


More information about the core-libs-dev mailing list