On Fri, 27 Jun 2025 15:03:05 GMT, Brian Burkhalter <[email protected]> wrote:
>> Replaces the implementation `readAllCharsAsString().lines().toList()` with
>> reading into a temporary `char` array which is then processed to detect line
>> terminators and copy non-terminating characters into strings which are added
>> to the list.
>
> Brian Burkhalter has updated the pull request incrementally with one
> additional commit since the last revision:
>
> 8358533: Test change accidentally omitted from previous commit
src/java.base/share/classes/java/io/Reader.java line 477:
> 475: boolean isCR = (cb[term] == '\r');
> 476: if (isCR || !(skipLF && term == pos)) {
> 477: // line terminator is a CR or an LF just after a
> CR
Suggestion:
// line terminator is a CR or an LF not after a CR
src/java.base/share/classes/java/io/Reader.java line 484:
> 482: lines.add(new String(cb, pos, term - pos));
> 483: }
> 484: }
This might be a good place to check for NL after CR and efficiently skip it.
(Common on Windows).
It could save a cycle through the `while (pos < limit)` loop just to ignore the
LF. (Except for the case of CR at the end of the buffer.)
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25863#discussion_r2172300601
PR Review Comment: https://git.openjdk.org/jdk/pull/25863#discussion_r2172307928