提交 d822e0a1 编写于 作者: B Behdad Esfahbod

[array] Adjust operator!=

See comments.
上级 203ea58b
......@@ -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.
*/
......
......@@ -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_)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册