RFR: 8354724: Methods in java.io.Reader to read all characters and all lines [v22]
Roger Riggs
rriggs at openjdk.org
Wed May 14 21:01:05 UTC 2025
On Wed, 14 May 2025 20:36:47 GMT, Markus KARG <duke at openjdk.org> wrote:
>> Actually I am working on exact these optimizations right now and do not like the idea that I have to file another JBS and PR just for a single code line. As `subSequence` typically *does* a copy (to not hold the original full text in-memory for the lifetime of a possibly single-character sub sequence), unless otherwise proven, `getChars` will always be faster. Having said that, I need to say, that I do not second what Chen said. In reality I have never seen "simple views", in particular not "frequently".
>
> BTW, paraphrasing Stuart here: "We want to reduce self-calls". `subSequence` is a self-call, *as we do not know* how it behaves in the actual implementation. For `getChars` we can be sure that it has no overridable side effects.
Both `subSequence` and `getChars` are implemented by the CharSequence.
They have the same level of trustworthiness about their implementation.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24728#discussion_r2089744639
More information about the core-libs-dev
mailing list