summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrcombs <rcombs@rcombs.me>2021-02-19 22:16:55 -0600
committerOneric <oneric@oneric.stub>2021-10-18 01:33:07 +0200
commit3b6e3d86b75b57b5242762379c0f2e919af0b025 (patch)
treea599f005bbe4f2b5c81f21dc9bc7fa40c125b4c3
parent1664e0ae23643c37f6ef227f6a51a0a070cd614c (diff)
downloadlibass-3b6e3d86b75b57b5242762379c0f2e919af0b025.tar.bz2
libass-3b6e3d86b75b57b5242762379c0f2e919af0b025.tar.xz
cache: switch to wyhash for cache tables
This is dramatically faster on files with large drawings.
-rw-r--r--libass/ass_cache.c24
-rw-r--r--libass/ass_cache.h2
2 files changed, 8 insertions, 18 deletions
diff --git a/libass/ass_cache.c b/libass/ass_cache.c
index 83b9588..2306008 100644
--- a/libass/ass_cache.c
+++ b/libass/ass_cache.c
@@ -30,26 +30,16 @@
#include "ass_outline.h"
#include "ass_cache.h"
-#define ASS_HASH_INIT 0x811c9dc5U
-#define FNV1_32A_PRIME 16777619U
+// Always enable native-endian mode, since we don't care about cross-platform consistency of the hash
+#define WYHASH_LITTLE_ENDIAN 1
+#include "wyhash.h"
+
+// With wyhash any arbitrary 64 bit value will suffice
+#define ASS_HASH_INIT 0xb3e46a540bd36cd4ULL
static inline ass_hashcode ass_hash_buf(const void *buf, size_t len, ass_hashcode hval)
{
- if (!len)
- return hval;
-
- const uint8_t *bp = buf;
- size_t n = (len + 3) / 4;
-
- switch (len % 4) {
- case 0: do { hval ^= *bp++; hval *= FNV1_32A_PRIME; //-fallthrough
- case 3: hval ^= *bp++; hval *= FNV1_32A_PRIME; //-fallthrough
- case 2: hval ^= *bp++; hval *= FNV1_32A_PRIME; //-fallthrough
- case 1: hval ^= *bp++; hval *= FNV1_32A_PRIME;
- } while (--n > 0);
- }
-
- return hval;
+ return wyhash(buf, len, hval, _wyp);
}
// type-specific functions
diff --git a/libass/ass_cache.h b/libass/ass_cache.h
index e96956c..6af2e79 100644
--- a/libass/ass_cache.h
+++ b/libass/ass_cache.h
@@ -26,7 +26,7 @@
#include "ass_bitmap.h"
typedef struct cache Cache;
-typedef uint32_t ass_hashcode;
+typedef uint64_t ass_hashcode;
// cache values