Encoding a string to a pre-existing array or MemorySegment can avoid creating intermediate arrays and efficient pack buffers.
For example, the existing APIs to UTF8 encode a string create one or more byte arrays depending on the encoding and string characters.
For example, the existing APIs to UTF8 encode a string create one or more byte arrays depending on the encoding and string characters.
- duplicates
-
JDK-8310901 Convert String::newStringNoRepl with Latin-1 to String::newStringLatin1NoRepl
-
- Closed
-
- relates to
-
JDK-4091286 (str) String.getBytes() is inefficient, can't pass dest byte[], app can't reuse buffs
-
- Open
-