On Wed, 14 May 2025 20:32:38 GMT, Markus KARG <d...@openjdk.org> wrote:
>> I have no idea whether `subSequence` is more performant than `getChars` but >> it seems cleaner. In any case, at this point we are concerned primarily with >> the APIs getting into JDK 25. We can improve performance after that. > > 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. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/24728#discussion_r2089706589