Merge 0b903eebdfa4d18907ce652bfaf33a2b676ec30c into bd9ae189f83e33a6977bbe056774c851e96fe0a7

This commit is contained in:
Glavo 2025-09-21 15:25:58 +08:00 committed by GitHub
commit f5c7ffe706
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -82,7 +82,7 @@ public final class MurmurHash2 {
// body
for (int i = 0; i < nblocks; i++) {
final int index = (i << 2);
int k = getLittleEndianInt(data, index);
int k = ByteArray.getIntLE(data, index);
k *= M32;
k ^= k >>> R32;
k *= M32;
@ -191,7 +191,7 @@ public final class MurmurHash2 {
// body
for (int i = 0; i < nblocks; i++) {
final int index = (i << 3);
long k = getLittleEndianLong(data, index);
long k = ByteArray.getLongLE(data, index);
k *= M64;
k ^= k >>> R64;
@ -294,36 +294,4 @@ public final class MurmurHash2 {
public static long hash64(final String text, final int from, final int length) {
return hash64(text.substring(from, from + length));
}
/**
* Gets the little-endian int from 4 bytes starting at the specified index.
*
* @param data The data
* @param index The index
* @return The little-endian int
*/
private static int getLittleEndianInt(final byte[] data, final int index) {
return ((data[index] & 0xff)) |
((data[index + 1] & 0xff) << 8) |
((data[index + 2] & 0xff) << 16) |
((data[index + 3] & 0xff) << 24);
}
/**
* Gets the little-endian long from 8 bytes starting at the specified index.
*
* @param data The data
* @param index The index
* @return The little-endian long
*/
private static long getLittleEndianLong(final byte[] data, final int index) {
return (((long) data[index] & 0xff)) |
(((long) data[index + 1] & 0xff) << 8) |
(((long) data[index + 2] & 0xff) << 16) |
(((long) data[index + 3] & 0xff) << 24) |
(((long) data[index + 4] & 0xff) << 32) |
(((long) data[index + 5] & 0xff) << 40) |
(((long) data[index + 6] & 0xff) << 48) |
(((long) data[index + 7] & 0xff) << 56);
}
}