mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-15 23:51:25 -07:00
Improve performance of tokenization and parsing
This commit is contained in:
@@ -223,3 +223,36 @@ void MurmurHash3_x86_128(void const *key, isize len, u32 seed, void *out) {
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
gb_internal gb_inline u32 murmur_32_scramble(u32 k) {
|
||||
k *= 0xcc9e2d51;
|
||||
k = (k << 15) | (k >> 17);
|
||||
k *= 0x1b873593;
|
||||
return k;
|
||||
}
|
||||
|
||||
u32 murmur3_32(u8 const *key, isize len, u32 seed) {
|
||||
u32 h = seed;
|
||||
u32 k;
|
||||
for (size_t i = len >> 2; i; i--) {
|
||||
memcpy(&k, key, sizeof(u32));
|
||||
key += sizeof(u32);
|
||||
h ^= murmur_32_scramble(k);
|
||||
h = (h << 13) | (h >> 19);
|
||||
h = h * 5 + 0xe6546b64;
|
||||
}
|
||||
k = 0;
|
||||
for (size_t i = len & 3; i; i--) {
|
||||
k <<= 8;
|
||||
k |= key[i - 1];
|
||||
}
|
||||
h ^= murmur_32_scramble(k);
|
||||
h ^= len;
|
||||
h ^= h >> 16;
|
||||
h *= 0x85ebca6b;
|
||||
h ^= h >> 13;
|
||||
h *= 0xc2b2ae35;
|
||||
h ^= h >> 16;
|
||||
return h;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user