diff --git a/src/hb-array.hh b/src/hb-array.hh index 1a22e15c0..a7553fc4e 100644 --- a/src/hb-array.hh +++ b/src/hb-array.hh @@ -458,21 +458,9 @@ inline uint32_t hb_array_t::hash () const { // FNV-1a hash function uint32_t current = /*cbf29ce4*/0x84222325; - unsigned i = 0; - -#if defined(__OPTIMIZE__) && !defined(HB_NO_PACKED) && \ - ((defined(__GNUC__) && __GNUC__ >= 5) || defined(__clang__)) - struct __attribute__((packed)) packed_uint32_t { uint32_t v; }; - for (; i + 4 <= this->length; i += 4) + for (auto &v : *this) { - current = current ^ hb_hash ((uint32_t) ((const packed_uint32_t *) &this->arrayZ[i])->v); - current = current * 16777619; - } -#endif - - for (; i < this->length; i++) - { - current = current ^ hb_hash (this->arrayZ[i]); + current = current ^ v; current = current * 16777619; } return current; @@ -483,21 +471,9 @@ inline uint32_t hb_array_t::hash () const { // FNV-1a hash function uint32_t current = /*cbf29ce4*/0x84222325; - unsigned i = 0; - -#if defined(__OPTIMIZE__) && !defined(HB_NO_PACKED) && \ - ((defined(__GNUC__) && __GNUC__ >= 5) || defined(__clang__)) - struct __attribute__((packed)) packed_uint32_t { uint32_t v; }; - for (; i + 4 <= this->length; i += 4) + for (auto &v : *this) { - current = current ^ hb_hash ((uint32_t) ((const packed_uint32_t *) &this->arrayZ[i])->v); - current = current * 16777619; - } -#endif - - for (; i < this->length; i++) - { - current = current ^ hb_hash (this->arrayZ[i]); + current = current ^ v; current = current * 16777619; } return current;