Revert "[array] Remove hash specializations for bytes"

This reverts commit 213117317c.
This commit is contained in:
Behdad Esfahbod 2022-11-21 23:08:51 -07:00
parent 1572ba281a
commit d7b492e3f5
1 changed files with 15 additions and 0 deletions

View File

@ -424,6 +424,21 @@ inline bool hb_array_t<const unsigned char>::operator == (const hb_array_t<const
return 0 == hb_memcmp (arrayZ, o.arrayZ, length);
}
template <>
inline uint32_t hb_array_t<const char>::hash () const {
uint32_t current = 0;
for (unsigned int i = 0; i < this->length; i++)
current = current * 31 + (uint32_t) (this->arrayZ[i] * 2654435761u);
return current;
}
template <>
inline uint32_t hb_array_t<const unsigned char>::hash () const {
uint32_t current = 0;
for (unsigned int i = 0; i < this->length; i++)
current = current * 31 + (uint32_t) (this->arrayZ[i] * 2654435761u);
return current;
}
typedef hb_array_t<const char> hb_bytes_t;
typedef hb_array_t<const unsigned char> hb_ubytes_t;