mirror of
https://github.com/harfbuzz/harfbuzz.git
synced 2025-04-13 08:42:59 +00:00
[vector] Minor micro-optimize shrink_vector
The compiler seems to understand this pattern better.
This commit is contained in:
parent
aed215639a
commit
3edd6cdcd5
1 changed files with 9 additions and 8 deletions
|
@ -374,14 +374,15 @@ struct hb_vector_t
|
|||
void
|
||||
shrink_vector (unsigned size)
|
||||
{
|
||||
if (std::is_trivially_destructible<Type>::value)
|
||||
length = size;
|
||||
else
|
||||
while ((unsigned) length > size)
|
||||
{
|
||||
arrayZ[(unsigned) length - 1].~Type ();
|
||||
length--;
|
||||
}
|
||||
assert (size <= length);
|
||||
if (!std::is_trivially_destructible<Type>::value)
|
||||
{
|
||||
unsigned count = length - size;
|
||||
Type *p = arrayZ + length - 1;
|
||||
while (count--)
|
||||
p--->~Type ();
|
||||
}
|
||||
length = size;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Reference in a new issue