[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 ()