From 4266cf3be266aef27a5d60530860915c68ba03e1 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 19 May 2022 18:15:46 -0600 Subject: [PATCH] [array] Specialize operator== for bytes_t and ubytes_t --- src/hb-array.hh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/hb-array.hh b/src/hb-array.hh index 417ffd5be..c7960dab7 100644 --- a/src/hb-array.hh +++ b/src/hb-array.hh @@ -404,7 +404,7 @@ hb_sorted_array (T (&array_)[length_]) { return hb_sorted_array_t (array_); } template -bool hb_array_t::operator == (const hb_array_t &o) const +inline bool hb_array_t::operator == (const hb_array_t &o) const { if (o.length != this->length) return false; for (unsigned int i = 0; i < this->length; i++) { @@ -412,8 +412,18 @@ bool hb_array_t::operator == (const hb_array_t &o) const } return true; } - -/* TODO Specialize operator== for hb_bytes_t and hb_ubytes_t. */ +template <> +inline bool hb_array_t::operator == (const hb_array_t &o) const +{ + if (o.length != this->length) return false; + return 0 == memcmp (arrayZ, o.arrayZ, length); +} +template <> +inline bool hb_array_t::operator == (const hb_array_t &o) const +{ + if (o.length != this->length) return false; + return 0 == memcmp (arrayZ, o.arrayZ, length); +} template <> inline uint32_t hb_array_t::hash () const { @@ -422,7 +432,6 @@ inline uint32_t hb_array_t::hash () const { current = current * 31 + (uint32_t) (this->arrayZ[i] * 2654435761u); return current; } - template <> inline uint32_t hb_array_t::hash () const { uint32_t current = 0;