From 59c7f7933b7cf65222bda047f2cf915fdae8b5fd Mon Sep 17 00:00:00 2001 From: John Naylor Date: Tue, 26 Dec 2023 13:10:26 +0700 Subject: [PATCH v11 8/8] Optimize loading tail when >= 4 bytes --- src/include/common/hashfn_unstable.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/include/common/hashfn_unstable.h b/src/include/common/hashfn_unstable.h index 5bc1fc88ec..79defbfeb5 100644 --- a/src/include/common/hashfn_unstable.h +++ b/src/include/common/hashfn_unstable.h @@ -113,6 +113,8 @@ fasthash_combine(fasthash_state *hs) static inline void fasthash_accum(fasthash_state *hs, const char *k, int len) { + uint32 lower_four; + Assert(hs->accum == 0); Assert(len <= FH_SIZEOF_ACCUM); @@ -131,8 +133,9 @@ fasthash_accum(fasthash_state *hs, const char *k, int len) hs->accum |= (uint64) k[4] << 32; /* FALLTHROUGH */ case 4: - hs->accum |= (uint64) k[3] << 24; - /* FALLTHROUGH */ + memcpy(&lower_four, k, sizeof(lower_four)); + hs->accum |= lower_four; + break; case 3: hs->accum |= (uint64) k[2] << 16; /* FALLTHROUGH */ -- 2.43.0