diff --git a/ds/dict.c b/ds/dict.c index 47b12c3..37d1bed 100644 --- a/ds/dict.c +++ b/ds/dict.c @@ -5,9 +5,6 @@ #include #include -#define HASH_OFFSET_BASIS 0xcbf29ce484222325 -#define HASH_PRIME 0x100000001b3 - /*** PRIVATE DATA *************************************************************/ struct fx_dict_bucket_item { @@ -45,11 +42,14 @@ static FX_BST_DEFINE_SIMPLE_INSERT( uint64_t fx_cstr_hash(const char *s) { - uint64_t hash = HASH_OFFSET_BASIS; +#define FNV1_OFFSET_BASIS 0xcbf29ce484222325 +#define FNV1_PRIME 0x100000001b3 + uint64_t hash = FNV1_OFFSET_BASIS; + size_t i = 0; - for (size_t i = 0; s[i]; i++) { - hash *= HASH_PRIME; + for (i = 0; s[i]; i++) { hash ^= s[i]; + hash *= FNV1_PRIME; } return hash; @@ -448,8 +448,8 @@ static void dict_to_string(const fx_object *obj, fx_stream *out) fx_object_to_string(item->bi_str, out); fx_stream_write_string(out, ": ", NULL); - bool is_string - = fx_object_is_type(item->bi_value, FX_TYPE_STRING); + bool is_string = fx_object_is_type( + item->bi_value, FX_TYPE_STRING); if (is_string) { fx_stream_write_char(out, '"');