[vector] Allocate exact size in constructor

This commit is contained in:
Behdad Esfahbod 2023-01-01 19:27:10 -07:00
parent 4dda1f7881
commit 449910d431
1 changed files with 3 additions and 3 deletions

View File

@ -45,7 +45,7 @@ struct hb_vector_t
hb_vector_t () = default;
hb_vector_t (std::initializer_list<Type> lst) : hb_vector_t ()
{
alloc (lst.size ());
alloc (lst.size (), true);
for (auto&& item : lst)
push (item);
}
@ -55,12 +55,12 @@ struct hb_vector_t
{
auto iter = hb_iter (o);
if (iter.is_random_access_iterator)
alloc (hb_len (iter));
alloc (hb_len (iter), true);
hb_copy (iter, *this);
}
hb_vector_t (const hb_vector_t &o) : hb_vector_t ()
{
alloc (o.length);
alloc (o.length, true);
if (unlikely (in_error ())) return;
copy_vector (o);
}