mirror of
https://github.com/harfbuzz/harfbuzz.git
synced 2025-04-13 16:50:38 +00:00
[vector] Speed up hb_vector_t<hb_vector_t<U>>::realloc_vector
Use in CFF subsetting.
This commit is contained in:
parent
b96eed0294
commit
d36b87bde4
1 changed files with 16 additions and 3 deletions
|
@ -255,7 +255,7 @@ struct hb_vector_t
|
|||
template <typename T = Type,
|
||||
hb_enable_if (hb_is_trivially_copy_assignable(T))>
|
||||
Type *
|
||||
realloc_vector (unsigned new_allocated)
|
||||
realloc_vector (unsigned new_allocated, hb_priority<0>)
|
||||
{
|
||||
if (!new_allocated)
|
||||
{
|
||||
|
@ -267,7 +267,7 @@ struct hb_vector_t
|
|||
template <typename T = Type,
|
||||
hb_enable_if (!hb_is_trivially_copy_assignable(T))>
|
||||
Type *
|
||||
realloc_vector (unsigned new_allocated)
|
||||
realloc_vector (unsigned new_allocated, hb_priority<0>)
|
||||
{
|
||||
if (!new_allocated)
|
||||
{
|
||||
|
@ -287,6 +287,19 @@ struct hb_vector_t
|
|||
}
|
||||
return new_array;
|
||||
}
|
||||
/* Specialization for hb_vector_t<hb_vector_t<U>> to speed up. */
|
||||
template <typename T = Type,
|
||||
hb_enable_if (hb_is_same(T, hb_vector_t<typename T::item_t>))>
|
||||
Type *
|
||||
realloc_vector (unsigned new_allocated, hb_priority<1>)
|
||||
{
|
||||
if (!new_allocated)
|
||||
{
|
||||
hb_free (arrayZ);
|
||||
return nullptr;
|
||||
}
|
||||
return (Type *) hb_realloc (arrayZ, new_allocated * sizeof (Type));
|
||||
}
|
||||
|
||||
template <typename T = Type,
|
||||
hb_enable_if (hb_is_trivially_constructible(T))>
|
||||
|
@ -418,7 +431,7 @@ struct hb_vector_t
|
|||
return false;
|
||||
}
|
||||
|
||||
Type *new_array = realloc_vector (new_allocated);
|
||||
Type *new_array = realloc_vector (new_allocated, hb_prioritize);
|
||||
|
||||
if (unlikely (new_allocated && !new_array))
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue