commit | f15858be5f09a9fdfbec9ccc68490e23e5db35ad | [log] [tgz] |
---|---|---|
author | Behdad Esfahbod <behdad@behdad.org> | Mon Nov 01 20:26:07 2021 -0600 |
committer | Behdad Esfahbod <behdad@behdad.org> | Mon Nov 01 20:26:07 2021 -0600 |
tree | e390e1dcc23709d06abf7d2ae667602761a4d433 | |
parent | 11135150a7e9955aefbf9ac943367a618b513981 [diff] |
[vector] Pre-allocate if iterator has random-access length
diff --git a/src/hb-vector.hh b/src/hb-vector.hh index 92c74dc..acd66a7 100644 --- a/src/hb-vector.hh +++ b/src/hb-vector.hh
@@ -51,6 +51,8 @@ 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 ()