[PATCH] [libcxx] Optimize vectors uninitialized construction of trivial types from an iterator range.

Marshall Clow mclow.lists at gmail.com
Tue Mar 17 07:53:12 PDT 2015


================
Comment at: include/vector:1393
@@ -1396,3 +1392,3 @@
 {
-    typename iterator_traits<_ForwardIterator>::difference_type __new_size = _VSTD::distance(__first, __last);
-    if (static_cast<size_type>(__new_size) <= capacity())
+    typename iterator_traits<_ForwardIterator>::difference_type __new_size_diff = _VSTD::distance(__first, __last);
+    size_type __new_size = static_cast<size_type>(__new_size_diff);
----------------
This requires traversing the sequence (in the case of non-RA iterators). Do we really want to do that?  Is it worth having a separate version for RA iterators?

http://reviews.llvm.org/D8109

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list