diff --git a/src/hb-vector.hh b/src/hb-vector.hh index e2263492b..8c8409d17 100644 --- a/src/hb-vector.hh +++ b/src/hb-vector.hh @@ -255,7 +255,7 @@ struct hb_vector_t template 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 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> to speed up. */ + template ))> + 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 @@ -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)) {