Optimize convert byte2int. (#13889)

This commit is contained in:
zhouhui 2024-10-15 22:12:48 +08:00 committed by GitHub
parent cf29597fec
commit 4d19a5408e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 2 deletions

View File

@ -775,10 +775,11 @@ public final class Util {
/** Just takes unsigned byte values from the BytesRef and converts into an IntsRef. */
public static IntsRef toIntsRef(BytesRef input, IntsRefBuilder scratch) {
scratch.clear();
scratch.growNoCopy(input.length);
for (int i = 0; i < input.length; i++) {
scratch.append(input.bytes[i + input.offset] & 0xFF);
scratch.setIntAt(i, input.bytes[i + input.offset] & 0xFF);
}
scratch.setLength(input.length);
return scratch.get();
}