In current implementation, we have the manual copy loops:
@HotSpotIntrinsicCandidate
public static byte[] toBytes(char[] value, int off, int len) {
byte[] val = new byte[len << 1];
for (int i = 0; i < len; i++) {
putChar(val, i, value[off++]);
}
return val;
}
....
byte buf[] = new byte[value.length];
for (int j = 0; j < i; j++) {
putChar(buf, j, getChar(value, j)); // TBD:arraycopy?
}
These can be substituted with System.arraycopy, Arrays.copyOf[Range], etc.
@HotSpotIntrinsicCandidate
public static byte[] toBytes(char[] value, int off, int len) {
byte[] val = new byte[len << 1];
for (int i = 0; i < len; i++) {
putChar(val, i, value[off++]);
}
return val;
}
....
byte buf[] = new byte[value.length];
for (int j = 0; j < i; j++) {
putChar(buf, j, getChar(value, j)); // TBD:arraycopy?
}
These can be substituted with System.arraycopy, Arrays.copyOf[Range], etc.