From d0da547b3741323493398eed8975a76f4a5742c2 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 2 Apr 2019 18:22:39 -0700 Subject: [PATCH] [array] Use dagger for hashing array Also switch to better mixing. --- src/hb-array.hh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/hb-array.hh b/src/hb-array.hh index 16f53cc8f..fc8d39d67 100644 --- a/src/hb-array.hh +++ b/src/hb-array.hh @@ -278,10 +278,11 @@ hb_sorted_array (T (&array_)[length_]) template uint32_t hb_array_t::hash () const { - uint32_t h = 0; - for (unsigned i = 0; i < length; i++) - h ^= hb_hash (arrayZ[i]); - return h; + return + + hb_iter (this) + | hb_map (hb_hash) + | hb_reduce ([] (uint32_t a, uint32_t b) -> uint32_t { return a * 31 + b; }, 0) + ; } typedef hb_array_t hb_bytes_t;