xxhash for ev & ui hashes

This commit is contained in:
Ryan Fleury
2024-11-08 14:57:58 -08:00
parent 5232ba298d
commit 04c1488cd4
2 changed files with 14 additions and 10 deletions
@@ -39,6 +39,12 @@ EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_DEF(identity)
////////////////////////////////
//~ rjf: Key Functions
#if !defined(XXH_IMPLEMENTATION)
# define XXH_IMPLEMENTATION
# define XXH_STATIC_LINKING_ONLY
# include "linker/third_party_ext/xxHash/xxhash.h"
#endif
internal EV_Key
ev_key_make(U64 parent_hash, U64 child_id)
{
@@ -74,11 +80,7 @@ ev_key_match(EV_Key a, EV_Key b)
internal U64
ev_hash_from_seed_string(U64 seed, String8 string)
{
U64 result = seed;
for(U64 i = 0; i < string.size; i += 1)
{
result = ((result << 5) + result) + string.str[i];
}
U64 result = XXH3_64bits_withSeed(string.str, string.size, seed);
return result;
}
+7 -5
View File
@@ -12,14 +12,16 @@ thread_static UI_State *ui_state = 0;
////////////////////////////////
//~ rjf: Basic Type Functions
#if !defined(XXH_IMPLEMENTATION)
# define XXH_IMPLEMENTATION
# define XXH_STATIC_LINKING_ONLY
# include "linker/third_party_ext/xxHash/xxhash.h"
#endif
internal U64
ui_hash_from_string(U64 seed, String8 string)
{
U64 result = seed;
for(U64 i = 0; i < string.size; i += 1)
{
result = ((result << 5) + result) + string.str[i];
}
U64 result = XXH3_64bits_withSeed(string.str, string.size, seed);
return result;
}