[array] Adjust operator!=

See comments.
This commit is contained in:
Behdad Esfahbod 2019-05-15 16:30:08 -07:00
parent 203ea58bf6
commit d822e0a16f
2 changed files with 7 additions and 1 deletions

View File

@ -84,8 +84,13 @@ struct hb_array_t : hb_iter_with_fallback_t<hb_array_t<Type>, 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.
*/

View File

@ -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_)