RFR: 8369564: Provide a MemorySegment API to read strings with known lengths [v12]

Liam Miller-Cushon cushon at openjdk.org
Tue Nov 25 09:51:39 UTC 2025


On Mon, 24 Nov 2025 15:13:28 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> Also, if in the future we also enhance encoders to return the length of a string w/o encoding it, it might still be useful to have `copy` return the length (to avoid scanning the string chars twice).

I agree, I think there are use-cases for both: if you expect to have enough room in the destination, it's better to avoid scanning the string twice, even if there's a more efficient way to compute the encoded length in the future.

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

PR Comment: https://git.openjdk.org/jdk/pull/28043#issuecomment-3574725230


More information about the core-libs-dev mailing list