From 921f45f46d2f973113d79fd68adb59ae8c0141af Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 18 Nov 2022 17:26:58 -0700 Subject: [PATCH] [array] Rewrite hash() as dagger --- src/hb-array.hh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hb-array.hh b/src/hb-array.hh index 0be896d94..1c66f7297 100644 --- a/src/hb-array.hh +++ b/src/hb-array.hh @@ -112,12 +112,12 @@ struct hb_array_t : hb_iter_with_fallback_t, Type&> HB_INTERNAL bool operator == (const hb_array_t &o) const; - uint32_t hash () const { - uint32_t current = 0; - for (unsigned int i = 0; i < this->length; i++) { - current = current * 31 + hb_hash (this->arrayZ[i]); - } - return current; + uint32_t hash () const + { + return + + hb_iter (*this) + | hb_reduce ([] (uint32_t h, const Type &_) { return h * 31 + hb_hash (_); }, (uint32_t) 0u) + ; } /*