Java has no performant API to access String content. Colfer version 1 uses charAt which causes range checks on every UTF-16 character. All other access methods are even slower due to memory allocation.
for (java.lang.reflect.Field f : String.class.getDeclaredFields())
System.err.printf("%s %s %s\n", java.lang.reflect.Modifier.toString(f.getModifiers()), f.getType().getTypeName(), f.getName());
The String class in LTS version 8 has a private final char[] value payload. LTS version 11, 17, 21, and the OpenJDK moved to the following layout.
private final byte[] value
private final byte coder
static final boolean COMPACT_STRINGS
static final byte LATIN1
static final byte UTF16
The coder can be either LATIN1 for ISO 8859-1, or UTF-16 for big-endian bytes. COMPACT_STRINGS must be read as well because LATIN1 is 0 and UTF-16 is 1 instead of the other way around. π€¦
Java has no performant API to access
Stringcontent. Colfer version 1 usescharAtwhich causes range checks on every UTF-16 character. All other access methods are even slower due to memory allocation.The
Stringclass in LTS version 8 has aprivate final char[] valuepayload. LTS version 11, 17, 21, and the OpenJDK moved to the following layout.The
codercan be eitherLATIN1for ISO 8859-1, orUTF-16for big-endian bytes.COMPACT_STRINGSmust be read as well becauseLATIN1is0andUTF-16is1instead of the other way around. π€¦