diff --git a/src/hb-vector.hh b/src/hb-vector.hh index 8e11d65ee..23a96d708 100644 --- a/src/hb-vector.hh +++ b/src/hb-vector.hh @@ -374,14 +374,15 @@ struct hb_vector_t void shrink_vector (unsigned size) { - if (std::is_trivially_destructible::value) - length = size; - else - while ((unsigned) length > size) - { - arrayZ[(unsigned) length - 1].~Type (); - length--; - } + assert (size <= length); + if (!std::is_trivially_destructible::value) + { + unsigned count = length - size; + Type *p = arrayZ + length - 1; + while (count--) + p--->~Type (); + } + length = size; } void