From 078b2a510189088ceda4cf23bc7c0197518831dd Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 8 May 2023 22:28:48 -0600 Subject: [PATCH] [hash] Use a Mersenne prime for int hash And hope that compiler optimizes to int ops instead of modula. Improves chaining it seems. Part of https://github.com/harfbuzz/harfbuzz/pull/4228 --- src/hb-algs.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hb-algs.hh b/src/hb-algs.hh index dbb18dc2b..e4889a6d8 100644 --- a/src/hb-algs.hh +++ b/src/hb-algs.hh @@ -316,7 +316,7 @@ struct // Horrible: std:hash() of integers seems to be identity in gcc / clang?! template constexpr auto - impl (const T& v, hb_priority<1>) const HB_RETURN (uint32_t, v * 2654435761u) + impl (const T& v, hb_priority<1>) const HB_RETURN (uint32_t, v * 8388607) template constexpr auto impl (const T& v, hb_priority<0>) const HB_RETURN (uint32_t, std::hash>{} (hb_deref (v)))