diff options
author | Adrian Johnson <ajohnson@redneon.com> | 2021-07-25 06:24:34 +0930 |
---|---|---|
committer | Adrian Johnson <ajohnson@redneon.com> | 2021-07-25 11:06:52 +0930 |
commit | 62681fe0523ae96a29e2ff9c080a4c0f4ad40d4c (patch) | |
tree | a6d185620039463ba9e4d3b8b02db2d4a9db3b21 /src/cairo-scaled-font.c | |
parent | 8d14a20a0009a8e832cb87fd9cf829bd399aa692 (diff) | |
download | cairo-62681fe0523ae96a29e2ff9c080a4c0f4ad40d4c.tar.gz |
Change FNV hash to 64-bit
Most builds are 64-bit where the uintptr_t type of the hash value and the font
face pointer that is being hashed are 64-bit.
Diffstat (limited to 'src/cairo-scaled-font.c')
-rwxr-xr-x | src/cairo-scaled-font.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c index 9a6270df3..65c1d2595 100755 --- a/src/cairo-scaled-font.c +++ b/src/cairo-scaled-font.c @@ -598,25 +598,25 @@ _cairo_scaled_font_placeholder_wait_for_creation_to_finish (cairo_scaled_font_t * well tested with binary data. */ -#define FNV_32_PRIME ((uint32_t)0x01000193) -#define FNV1_32_INIT ((uint32_t)0x811c9dc5) +#define FNV_64_PRIME ((uint64_t)0x00000100000001B3) +#define FNV1_64_INIT ((uint64_t)0xcbf29ce484222325) -static uint32_t +static uint64_t _hash_matrix_fnv (const cairo_matrix_t *matrix, - uint32_t hval) + uint64_t hval) { const uint8_t *buffer = (const uint8_t *) matrix; int len = sizeof (cairo_matrix_t); do { - hval *= FNV_32_PRIME; + hval *= FNV_64_PRIME; hval ^= *buffer++; } while (--len); return hval; } -static uint32_t -_hash_mix_bits (uint32_t hash) +static uint64_t +_hash_mix_bits (uint64_t hash) { hash += hash << 12; hash ^= hash >> 7; @@ -629,7 +629,7 @@ _hash_mix_bits (uint32_t hash) static uintptr_t _cairo_scaled_font_compute_hash (cairo_scaled_font_t *scaled_font) { - uintptr_t hash = FNV1_32_INIT; + uintptr_t hash = FNV1_64_INIT; /* We do a bytewise hash on the font matrices */ hash = _hash_matrix_fnv (&scaled_font->font_matrix, hash); |