summaryrefslogtreecommitdiff
path: root/apt-pkg/pkgcachegen.h
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2020-12-13 21:07:03 +0100
committerJulian Andres Klode <julian.klode@canonical.com>2020-12-15 13:47:22 +0100
commit1460eebf2abe913df964e031eff081a57f043697 (patch)
treebe92fe9f5d240d7d448f57805445fe20a265e79b /apt-pkg/pkgcachegen.h
parentb6c8c5ce2b255eb03554435a620934d47a2a14d5 (diff)
Use XXH3 for cache, hash table hashing
XXH3 is faster than both our CRC32c implementation as well as DJB hash for hash table hashing, so meh, let's switch to it.
Diffstat (limited to 'apt-pkg/pkgcachegen.h')
-rw-r--r--apt-pkg/pkgcachegen.h8
1 files changed, 3 insertions, 5 deletions
diff --git a/apt-pkg/pkgcachegen.h b/apt-pkg/pkgcachegen.h
index f5b4c80b3..9a88b45e7 100644
--- a/apt-pkg/pkgcachegen.h
+++ b/apt-pkg/pkgcachegen.h
@@ -29,6 +29,8 @@
#endif
#include <apt-pkg/string_view.h>
+#include <xxhash.h>
+
class FileFd;
class pkgSourceList;
class OpProgress;
@@ -63,11 +65,7 @@ class APT_HIDDEN pkgCacheGenerator /*{{{*/
};
struct hash {
uint32_t operator()(string_pointer const &that) const {
- uint32_t Hash = 5381;
- const char * const end = that.data() + that.size;
- for (const char *I = that.data(); I != end; ++I)
- Hash = 33 * Hash + *I;
- return Hash;
+ return XXH3_64bits(that.data(), that.size) & 0xFFFFFFFF;
}
};