From 772a3affce619cc43565440aaa5a50cf2ed19017 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kittywhiskers@users.noreply.github.com> Date: Thu, 6 Jan 2022 11:27:06 -0500 Subject: [PATCH] merge bitcoin#23994: Consolidate all uses of the fast range mapping technique in util/fastrange.h --- src/Makefile.am | 1 + src/blockfilter.cpp | 2 +- src/bloom.cpp | 13 +++------ src/cuckoocache.h | 27 +++++++++---------- src/test/fuzz/golomb_rice.cpp | 2 +- src/util/fastrange.h | 51 +++++++++++++++++++++++++++++++++++ src/util/golombrice.h | 33 ++--------------------- 7 files changed, 71 insertions(+), 58 deletions(-) create mode 100644 src/util/fastrange.h diff --git a/src/Makefile.am b/src/Makefile.am index 3b642102e2..d27f3bf59b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -310,6 +310,7 @@ BITCOIN_CORE_H = \ util/check.h \ util/enumerate.h \ util/error.h \ + util/fastrange.h \ util/fees.h \ util/golombrice.h \ util/hash_type.h \ diff --git a/src/blockfilter.cpp b/src/blockfilter.cpp index 1097841379..551486fb78 100644 --- a/src/blockfilter.cpp +++ b/src/blockfilter.cpp @@ -29,7 +29,7 @@ uint64_t GCSFilter::HashToRange(const Element& element) const uint64_t hash = CSipHasher(m_params.m_siphash_k0, m_params.m_siphash_k1) .Write(element.data(), element.size()) .Finalize(); - return MapIntoRange(hash, m_F); + return FastRange64(hash, m_F); } std::vector GCSFilter::BuildHashedSet(const ElementSet& elements) const diff --git a/src/bloom.cpp b/src/bloom.cpp index 4003c95c5a..b9508b3da1 100644 --- a/src/bloom.cpp +++ b/src/bloom.cpp @@ -14,6 +14,7 @@ #include