[hash] Links

This commit is contained in:
Behdad Esfahbod 2023-05-09 13:39:52 -06:00
parent 05567da082
commit b2b15fa30a
2 changed files with 5 additions and 1 deletions

View file

@ -315,7 +315,8 @@ 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?!
//
// https://github.com/harfbuzz/harfbuzz/pull/4228
template <typename T,
hb_enable_if (std::is_integral<T>::value && sizeof (T) <= sizeof (uint32_t))> constexpr auto
impl (const T& v, hb_priority<1>) const HB_RETURN (uint32_t, v * 8388607u /* Mersenne prime */)

View file

@ -123,6 +123,7 @@ struct hb_array_t : hb_iter_with_fallback_t<hb_array_t<Type>, Type&>
uint32_t hash () const
{
// FNV-1a hash function
// https://github.com/harfbuzz/harfbuzz/pull/4228
uint32_t current = /*cbf29ce4*/0x84222325;
for (auto &v : *this)
{
@ -456,12 +457,14 @@ inline bool hb_array_t<const unsigned char>::operator == (const hb_array_t<const
template <>
inline uint32_t hb_array_t<const char>::hash () const
{
// https://github.com/harfbuzz/harfbuzz/pull/4228
return fasthash32(arrayZ, length, 0xf437ffe6 /* magic? */);
}
template <>
inline uint32_t hb_array_t<const unsigned char>::hash () const
{
// https://github.com/harfbuzz/harfbuzz/pull/4228
return fasthash32(arrayZ, length, 0xf437ffe6 /* magic? */);
}