aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2022-08-27 23:49:27 -0400
committerGravatar Chris Xiong <chirs241097@gmail.com> 2022-08-27 23:49:27 -0400
commite679bf14a12b51554abe812026d9699451d53f1f (patch)
tree4a991812a06fc20f8891359cf836a4f79fdff515
parent137960a0261245a433f161d8fa4cbb53e4e50e6a (diff)
downloaddeduper-e679bf14a12b51554abe812026d9699451d53f1f.tar.xz
Add hash function for uncompressed signatures.
-rw-r--r--signature.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/signature.cpp b/signature.cpp
index cd55a77..fb2e757 100644
--- a/signature.cpp
+++ b/signature.cpp
@@ -288,5 +288,13 @@ signature_config signature::default_cfg()
size_t signature_hash::operator()(signature const& sig) const noexcept
{
- return compressed_vector_hash<uint8_t, 3>{}(sig.p->ct);
+ if (sig.p->compressed)
+ return compressed_vector_hash<uint8_t, 3>{}(sig.p->ct);
+ else
+ {
+ size_t ret = 0;
+ for (uint8_t &v : sig.p->uct)
+ ret ^= v + 0x9e3779b9 + (ret << 6) + (ret >> 2);
+ return ret;
+ }
}