core: dict: fix fx_cstr_hash using different constants than other string hashing functions

This commit is contained in:
2026-04-01 19:04:30 +01:00
parent 8eba5c7462
commit fc43d104dc
+8 -8
View File
@@ -5,9 +5,6 @@
#include <stdbool.h>
#include <stdlib.h>
#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, '"');