[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
pull/4228/head
Behdad Esfahbod 2 years ago
parent fe0f7dc57b
commit 078b2a5101
  1. 2
      src/hb-algs.hh

@ -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)))

Loading…
Cancel
Save