[vector] Speed up shrink_vector for trivial destructors

This commit is contained in:
Behdad Esfahbod 2023-06-08 18:47:33 -06:00
parent da2e2c8c25
commit 0935b32795

View file

@ -351,11 +351,14 @@ struct hb_vector_t
void
shrink_vector (unsigned size)
{
while ((unsigned) length > size)
{
arrayZ[(unsigned) length - 1].~Type ();
length--;
}
if (std::is_trivially_destructible<Type>::value)
length = size;
else
while ((unsigned) length > size)
{
arrayZ[(unsigned) length - 1].~Type ();
length--;
}
}
void