RFR: 8333843: Provide methods on MemorySegment to read strings with known lengths

Maurizio Cimadamore mcimadamore at openjdk.org
Wed Aug 28 10:08:19 UTC 2024


On Wed, 28 Aug 2024 09:57:42 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> Ok, I suppose what you do get is the auto-detection of charset length, which adjusts the size of the copy...

NVM, this is not what this impl is doing. I see no performance benefit for using the new API over a `copy`. If so, this new API is just for ease of use. While that's ok, IMHO it's not an easy API to add, as we're making a number of arbitrary choices here:
* what to do with terminators in the middle of the string
* whether length is length of string in chars, or length in bytes (we do the latter)

This leaves me a bit skeptical that this API is the right primitive.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20725#discussion_r1734379824


More information about the core-libs-dev mailing list