[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
This commit is contained in:
Behdad Esfahbod 2023-05-08 22:28:48 -06:00
parent fe0f7dc57b
commit 078b2a5101

View file

@ -316,7 +316,7 @@ struct
// Horrible: std:hash() of integers seems to be identity in gcc / clang?!
template <typename T> 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 <typename T> constexpr auto
impl (const T& v, hb_priority<0>) const HB_RETURN (uint32_t, std::hash<hb_decay<decltype (hb_deref (v))>>{} (hb_deref (v)))