From fe3339ea241528652f3480fb061abca3c6bb2ed8 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 9 May 2023 11:31:06 -0600 Subject: [PATCH] [algs] Add hash for 64bit ints --- src/hb-algs.hh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/hb-algs.hh b/src/hb-algs.hh index dde075243..5629d7594 100644 --- a/src/hb-algs.hh +++ b/src/hb-algs.hh @@ -315,10 +315,15 @@ struct impl (const T& v, hb_priority<2>) const HB_RETURN (uint32_t, hb_deref (v).hash ()) // Horrible: std:hash() of integers seems to be identity in gcc / clang?! + // template ::value)> constexpr auto + hb_enable_if (std::is_integral::value && sizeof (T) <= sizeof (uint32_t))> constexpr auto impl (const T& v, hb_priority<1>) const HB_RETURN (uint32_t, v * 8388607u /* Mersenne prime */) + template ::value && sizeof (T) > sizeof (uint32_t))> constexpr auto + impl (const T& v, hb_priority<1>) const HB_RETURN (uint32_t, (v * 8388607u) ^ ((v >> 32) * 8388607u) /* Mersenne prime */) + template constexpr auto impl (const T& v, hb_priority<0>) const HB_RETURN (uint32_t, std::hash>{} (hb_deref (v)))