From b475a2ab29eec981ac92c5ebc555b2c30288fe57 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 17 Jul 2022 18:44:11 -0600 Subject: [PATCH] [array] Adjust operator != --- src/hb-array.hh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/hb-array.hh b/src/hb-array.hh index 410d72a1f..826a90181 100644 --- a/src/hb-array.hh +++ b/src/hb-array.hh @@ -100,10 +100,9 @@ struct hb_array_t : hb_iter_with_fallback_t, Type&> /* 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(). */ + * for range-based for loop and just compare arrayZ and length. */ bool operator != (const hb_array_t& o) const - { return arrayZ != o.arrayZ; } + { return this->arrayZ != o.arrayZ || this->length != o.length; } /* Extra operators. */ @@ -325,6 +324,8 @@ struct hb_sorted_array_t : { hb_array_t (*this) = o; return *this; } /* Iterator implementation. */ + + /* See comment in hb_array_of::operator != */ bool operator != (const hb_sorted_array_t& o) const { return this->arrayZ != o.arrayZ || this->length != o.length; }