diff --git a/fx.collections/dict.c b/fx.collections/dict.c index 632cd49..421d67e 100644 --- a/fx.collections/dict.c +++ b/fx.collections/dict.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -47,21 +48,6 @@ static FX_BST_DEFINE_SIMPLE_INSERT( bk_hash, put_bucket); -uint64_t fx_cstr_hash(const char *s) -{ -#define FNV1_OFFSET_BASIS 0xcbf29ce484222325 -#define FNV1_PRIME 0x100000001b3 - uint64_t hash = FNV1_OFFSET_BASIS; - size_t i = 0; - - for (i = 0; s[i]; i++) { - hash ^= s[i]; - hash *= FNV1_PRIME; - } - - return hash; -} - /*** PRIVATE FUNCTIONS ********************************************************/ static struct fx_dict_bucket *create_bucket(void) @@ -91,7 +77,7 @@ static fx_status dict_put( const char *key, fx_object *value) { - uint64_t hash = fx_cstr_hash(key); + uint64_t hash = fx_hash_cstr(key); struct fx_dict_bucket *bucket = get_bucket(&dict->d_buckets, hash); if (!bucket) { bucket = create_bucket(); @@ -148,7 +134,7 @@ static fx_status dict_put_sk( static fx_object *dict_at(const struct fx_dict_p *dict, const char *key) { - uint64_t hash = fx_cstr_hash(key); + uint64_t hash = fx_hash_cstr(key); struct fx_dict_bucket *bucket = get_bucket(&dict->d_buckets, hash); if (!bucket) { return NULL;