On Wed, 23 Apr 2025 22:04:25 GMT, Brian Burkhalter <b...@openjdk.org> wrote:

>> Implement the requested methods and add a test thereof.
>
> Brian Burkhalter has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   8354724: Fix readAllChars gaffe in Reader returned by Readed.of and account 
> for it in test

src/java.base/share/classes/java/io/Reader.java line 213:

> 211:             public String readAllChars() throws IOException {
> 212:                 ensureOpen();
> 213:                 return cs.toString().substring(next);

Your change implies creating a full-length string *first* (including cyoping 
and compression), just to strip it down to a smaller one *later*. It would be 
more efficient to *first* strip it down, and compression into a `String` 
*afterwards*. Imagine a huge `cs` with `next` being near to `length()`, and you 
see the difference in efficiency! 🙂 

`cs.subSequence(next, cs.length() - next).toString()`

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24728#discussion_r2072340583

Reply via email to