Update Murmur3 hasher IO
Release / release (push) Successful in 3s

This commit is contained in:
2026-08-30 23:50:22 +01:00
parent 55ff77c4ea
commit 850f709a10
4 changed files with 10 additions and 11 deletions
+2 -2
View File
@@ -90,8 +90,8 @@ void wpX64Mur3Hasher128(WpU8Stream *bytes, void *hasher_io) {
h1 += h2; h1 += h2;
h2 += h1; h2 += h1;
io->out_hash1 = h1; io->hash[0] = h1;
io->out_hash2 = h2; io->hash[1] = h2;
} }
wp_intern inline u64 fmix64(u64 k) { wp_intern inline u64 fmix64(u64 k) {
+2 -3
View File
@@ -19,14 +19,13 @@ BEGIN_C_LINKAGE
#define WP_MUR3_HASHER_MAGIC ((u64)0x57504d4841534833) #define WP_MUR3_HASHER_MAGIC ((u64)0x57504d4841534833)
typedef struct { typedef struct {
u64 hash[2];
u64 magic; u64 magic;
u64 out_hash1;
u64 out_hash2;
u32 seed; u32 seed;
} WpMur3HasherIO; } WpMur3HasherIO;
#ifdef WP_PLATFORM_CPP #ifdef WP_PLATFORM_CPP
#define wpMur3HasherIO(SEED) (WpMur3HasherIO{WP_MUR3_HASHER_MAGIC, 0, 0, SEED}) #define wpMur3HasherIO(SEED) (WpMur3HasherIO{{}, WP_MUR3_HASHER_MAGIC, SEED})
#else #else
#define wpMur3HasherIO(SEED) ((WpMur3HasherIO){ .magic = WP_MUR3_HASHER_MAGIC, .seed = SEED }) #define wpMur3HasherIO(SEED) ((WpMur3HasherIO){ .magic = WP_MUR3_HASHER_MAGIC, .seed = SEED })
#endif #endif
+3 -3
View File
@@ -23,19 +23,19 @@ WpTestFuncResult test_murmur3(void) {
wpX64Mur3Hasher128(&str_bytes, (void *)&io); wpX64Mur3Hasher128(&str_bytes, (void *)&io);
MurmurHash3_x64_128(str_bytes.data, str_bytes.count * str_bytes.item_size, io.seed, (void *)hash); MurmurHash3_x64_128(str_bytes.data, str_bytes.count * str_bytes.item_size, io.seed, (void *)hash);
result = result && io.out_hash1 == hash[0] && io.out_hash2 == hash[1]; result = result && io.hash[0] == hash[0] && io.hash[1] == hash[1];
// Array hash // Array hash
wpX64Mur3Hasher128(&arr_bytes, (void *)&io); wpX64Mur3Hasher128(&arr_bytes, (void *)&io);
MurmurHash3_x64_128(arr_bytes.data, arr_bytes.count * arr_bytes.item_size, io.seed, (void *)hash); MurmurHash3_x64_128(arr_bytes.data, arr_bytes.count * arr_bytes.item_size, io.seed, (void *)hash);
result = result && io.out_hash1 == hash[0] && io.out_hash2 == hash[1]; result = result && io.hash[0] == hash[0] && io.hash[1] == hash[1];
// Number hash // Number hash
wpX64Mur3Hasher128(&num_bytes, (void *)&io); wpX64Mur3Hasher128(&num_bytes, (void *)&io);
MurmurHash3_x64_128(num_bytes.data, num_bytes.count * num_bytes.item_size, io.seed, (void *)hash); MurmurHash3_x64_128(num_bytes.data, num_bytes.count * num_bytes.item_size, io.seed, (void *)hash);
result = result && io.out_hash1 == hash[0] && io.out_hash2 == hash[1]; result = result && io.hash[0] == hash[0] && io.hash[1] == hash[1];
return wpTesterResult(result); return wpTesterResult(result);
} }
+3 -3
View File
@@ -23,19 +23,19 @@ WpTestFuncResult test_murmur3(void) {
wpX64Mur3Hasher128(&str_bytes, (void *)&io); wpX64Mur3Hasher128(&str_bytes, (void *)&io);
MurmurHash3_x64_128(str_bytes.data, str_bytes.count * str_bytes.item_size, io.seed, (void *)hash); MurmurHash3_x64_128(str_bytes.data, str_bytes.count * str_bytes.item_size, io.seed, (void *)hash);
result = result && io.out_hash1 == hash[0] && io.out_hash2 == hash[1]; result = result && io.hash[0] == hash[0] && io.hash[1] == hash[1];
// Array hash // Array hash
wpX64Mur3Hasher128(&arr_bytes, (void *)&io); wpX64Mur3Hasher128(&arr_bytes, (void *)&io);
MurmurHash3_x64_128(arr_bytes.data, arr_bytes.count * arr_bytes.item_size, io.seed, (void *)hash); MurmurHash3_x64_128(arr_bytes.data, arr_bytes.count * arr_bytes.item_size, io.seed, (void *)hash);
result = result && io.out_hash1 == hash[0] && io.out_hash2 == hash[1]; result = result && io.hash[0] == hash[0] && io.hash[1] == hash[1];
// Number hash // Number hash
wpX64Mur3Hasher128(&num_bytes, (void *)&io); wpX64Mur3Hasher128(&num_bytes, (void *)&io);
MurmurHash3_x64_128(num_bytes.data, num_bytes.count * num_bytes.item_size, io.seed, (void *)hash); MurmurHash3_x64_128(num_bytes.data, num_bytes.count * num_bytes.item_size, io.seed, (void *)hash);
result = result && io.out_hash1 == hash[0] && io.out_hash2 == hash[1]; result = result && io.hash[0] == hash[0] && io.hash[1] == hash[1];
return wpTesterResult(result); return wpTesterResult(result);
} }