fromCharArray
trys to mimic following jdk code: however, in lucene context, COMPACT_STRINGS is always true, so gnore the check
Private constructor. Trailing Void argument is there for disambiguating it against other (public) constructors.
Stores the char[] value into a byte[] that each byte represents the8 low-order bits of the corresponding character, if the char[] contains only latin1 character. Or a byte[] that stores all characters in their byte sequences defined by the {@code StringUTF16}.
The contents of the string are unspecified if the character array is modified during string construction.
private String(char[] value, int off, int len, Void sig) {
if (len == 0) {
this_value = "".value;
this_coder = "".coder;
return;
}
if (COMPACT_STRINGS) {
byte[] val = StringUTF16.compress(value, off, len);
this_coder = StringUTF16.coderFromArrayLen(val, len);
this_value = val;
return;
}
this_coder = UTF16;
this_value = StringUTF16.toBytes(value, off, len);
}Content copied to clipboard