determining array base offset: replaced trick code with proper code

This commit is contained in:
minjaesong
2020-02-27 17:54:35 +09:00
parent e235b81041
commit 1524919ae0
5 changed files with 25 additions and 34 deletions

View File

@@ -17,8 +17,6 @@ public class XXHash32 {
static final int PRIME4 = 0x27D4EB2F;
static final int PRIME5 = 0x165667B1;
static final int ARRAY_ELEM_OFFSET = (AppLoader.is32BitJVM) ? 8 : 16;
public static int hash(byte[] data, int seed) {
int end = data.length;
int offset = 0;
@@ -74,6 +72,6 @@ public class XXHash32 {
}
protected static int getInt(byte[] data, int offset) {
return UnsafeHelper.INSTANCE.getUnsafe().getInt(data, offset + ARRAY_ELEM_OFFSET);
return UnsafeHelper.INSTANCE.getUnsafe().getInt(data, offset + UnsafeHelper.INSTANCE.getArrayOffset(data));
}
}