core: dict: fix fx_cstr_hash using different constants than other string hashing functions
This commit is contained in:
@@ -5,9 +5,6 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define HASH_OFFSET_BASIS 0xcbf29ce484222325
|
|
||||||
#define HASH_PRIME 0x100000001b3
|
|
||||||
|
|
||||||
/*** PRIVATE DATA *************************************************************/
|
/*** PRIVATE DATA *************************************************************/
|
||||||
|
|
||||||
struct fx_dict_bucket_item {
|
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 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++) {
|
for (i = 0; s[i]; i++) {
|
||||||
hash *= HASH_PRIME;
|
|
||||||
hash ^= s[i];
|
hash ^= s[i];
|
||||||
|
hash *= FNV1_PRIME;
|
||||||
}
|
}
|
||||||
|
|
||||||
return hash;
|
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_object_to_string(item->bi_str, out);
|
||||||
fx_stream_write_string(out, ": ", NULL);
|
fx_stream_write_string(out, ": ", NULL);
|
||||||
|
|
||||||
bool is_string
|
bool is_string = fx_object_is_type(
|
||||||
= fx_object_is_type(item->bi_value, FX_TYPE_STRING);
|
item->bi_value, FX_TYPE_STRING);
|
||||||
|
|
||||||
if (is_string) {
|
if (is_string) {
|
||||||
fx_stream_write_char(out, '"');
|
fx_stream_write_char(out, '"');
|
||||||
|
|||||||
Reference in New Issue
Block a user