diff --git a/src/hb-vector.hh b/src/hb-vector.hh index a474a7ba5..636e125c5 100644 --- a/src/hb-vector.hh +++ b/src/hb-vector.hh @@ -232,6 +232,26 @@ struct hb_vector_t return new_array; } + template ::value)> + void + grow_vector (unsigned size) + { + memset (arrayZ + length, 0, (size - length) * sizeof (*arrayZ)); + length = size; + } + template ::value)> + void + grow_vector (unsigned size) + { + while (length < size) + { + length++; + new (std::addressof (arrayZ[length - 1])) Type (); + } + } + template ::value)> void @@ -294,8 +314,7 @@ struct hb_vector_t return false; if (size > length) - // XXX construct objects. - memset (arrayZ + length, 0, (size - length) * sizeof (*arrayZ)); + grow_vector (size); else if (size < length) shrink_vector (size);