From c13164dde843246b452bc565e93469c03ddaa07d Mon Sep 17 00:00:00 2001 From: EntireTwix Date: Tue, 29 Jun 2021 15:06:18 -0700 Subject: [PATCH] :racehorse: made phmap use xxhash as hashing --- include/bank.h | 3 ++- include/xxhash_strfunctor.hpp | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 include/xxhash_strfunctor.hpp diff --git a/include/bank.h b/include/bank.h index 9f4ca41..a4ec78e 100644 --- a/include/bank.h +++ b/include/bank.h @@ -4,6 +4,7 @@ #include #include #include +#include "xxhash_strfunctor.hpp" #include "user.h" #if CONSERVATIVE_DISK_SAVE && MAX_LOG_SIZE < 0 @@ -16,7 +17,7 @@ class Bank { phmap::parallel_flat_hash_map< std::string, User, - phmap::priv::hash_default_hash, + xxHashStringGen, phmap::priv::hash_default_eq, phmap::priv::Allocator>, 4UL, diff --git a/include/xxhash_strfunctor.hpp b/include/xxhash_strfunctor.hpp new file mode 100644 index 0000000..cddbe3f --- /dev/null +++ b/include/xxhash_strfunctor.hpp @@ -0,0 +1,12 @@ +#pragma once +#include +#include +#include + +struct xxHashStringGen +{ + inline uint64_t operator()(const std::string &str) const + { + return XXH3_64bits(str.data(), str.size()); + } +}; \ No newline at end of file