[vector] Pre-allocate if iterator has random-access length

This commit is contained in:
Behdad Esfahbod 2021-11-01 20:26:07 -06:00
parent 11135150a7
commit f15858be5f
1 changed files with 2 additions and 0 deletions

View File

@ -51,6 +51,8 @@ struct hb_vector_t
hb_requires (hb_is_iterable (Iterable))>
hb_vector_t (const Iterable &o) : hb_vector_t ()
{
if (hb_iter (o).is_random_access_iterator)
alloc (hb_len (hb_iter (o)));
hb_copy (o, *this);
}
hb_vector_t (const hb_vector_t &o) : hb_vector_t ()