diff options
| author | gingerBill <bill@gingerbill.org> | 2020-05-27 12:32:11 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2020-05-27 12:32:11 +0100 |
| commit | 6ac0fb80a6eab6ba28838e8e577dc8ae8cba06a7 (patch) | |
| tree | 9bf9a7315b8344f3a44fb019680bb41bf5c8332f /src/common.cpp | |
| parent | 098699103da15894be771ce7c5f28812fd6de883 (diff) | |
Minor tokenizer performance improvements
Diffstat (limited to 'src/common.cpp')
| -rw-r--r-- | src/common.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/common.cpp b/src/common.cpp index a0d69b308..7068eb333 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -158,7 +158,15 @@ GB_ALLOCATOR_PROC(heap_allocator_proc) { #include "range_cache.cpp" - +u32 fnv32a(void const *data, isize len) { + u8 const *bytes = cast(u8 const *)data; + u32 h = 0x811c9dc5; + for (isize i = 0; i < len; i++) { + u32 b = cast(u32)bytes[i]; + h = (h ^ b) * 0x01000193; + } + return h; +} u64 fnv64a(void const *data, isize len) { u8 const *bytes = cast(u8 const *)data; |