[libcxx-commits] [libcxx] [libc++] Optimize vector::erase (PR #213916)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Aug 12 07:20:35 PDT 2026


================
@@ -1014,9 +1039,31 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::assign(size_type __n
 
 template <class _Tp, class _Allocator>
 _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::reserve(size_type __n) {
-  if (__n > capacity()) {
-    if (__n > max_size())
-      this->__throw_length_error();
+  if (__n <= capacity())
+    return;
+
+  if (__n > max_size())
+    this->__throw_length_error();
+
+#ifndef _LIBCPP_CXX03_LANG
+  if constexpr (__is_nothrow_relocatable_v<_Tp>) {
----------------
ldionne wrote:

Is this intended for this PR?

https://github.com/llvm/llvm-project/pull/213916


More information about the libcxx-commits mailing list