From 5d0cc0062a75013a388f6929b59cbfa7939dc6e1 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 9 May 2023 18:40:35 -0600 Subject: [PATCH] [hash] Disable int hash as it has negative performance gain --- src/hb-algs.hh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/hb-algs.hh b/src/hb-algs.hh index e8ce0a36c..1130219c8 100644 --- a/src/hb-algs.hh +++ b/src/hb-algs.hh @@ -314,6 +314,13 @@ struct template constexpr auto impl (const T& v, hb_priority<2>) const HB_RETURN (uint32_t, hb_deref (v).hash ()) +#if 0 + // The following, unfortunately, while keeps the probing chains short, slows + // down the overall hash table performance. Not because of the extra operation + // itself in my opinion, but something else going on that we have not been able + // to track down. So for now, this is disabled. Discuss: + // https://github.com/harfbuzz/harfbuzz/pull/4228 + // Horrible: std:hash() of integers seems to be identity in gcc / clang?! // https://github.com/harfbuzz/harfbuzz/pull/4228 @@ -324,6 +331,7 @@ struct template ::value && sizeof (T) > sizeof (uint32_t))> constexpr auto impl (const T& v, hb_priority<1>) const HB_RETURN (uint32_t, (v ^ (v >> 32)) * 131071u /* Mersenne prime */) +#endif template constexpr auto impl (const T& v, hb_priority<0>) const HB_RETURN (uint32_t, std::hash>{} (hb_deref (v)))