diff --git a/src/hb-array.hh b/src/hb-array.hh index ae0d16684..587000cd4 100644 --- a/src/hb-array.hh +++ b/src/hb-array.hh @@ -84,8 +84,13 @@ struct hb_array_t : hb_iter_with_fallback_t, Type&> arrayZ -= n; } unsigned __len__ () const { return length; } + /* Ouch. The operator== compares the contents of the array. For range-based for loops, + * it's best if we can just compare arrayZ, though comparing contents is still fast, + * but also would require that Type has operator==. As such, we optimize this operator + * for range-based for loop and just compare arrayZ. No need to compare length, as we + * assume we're only compared to .end(). */ bool operator != (const hb_array_t& o) const - { return arrayZ != o.arrayZ || length != o.length || backwards_length != o.backwards_length; } + { return arrayZ != o.arrayZ; } /* Extra operators. */ diff --git a/src/hb-vector.hh b/src/hb-vector.hh index 3c6347b3f..de16c97dd 100644 --- a/src/hb-vector.hh +++ b/src/hb-vector.hh @@ -103,6 +103,7 @@ struct hb_vector_t { return hb_bytes_t ((const char *) arrayZ, length * item_size); } bool operator == (const hb_vector_t &o) const { return as_array () == o.as_array (); } + bool operator != (const hb_vector_t &o) const { return !(*this == o); } uint32_t hash () const { return as_array ().hash (); } Type& operator [] (int i_)