[libcxx-commits] [libcxx] [libc++][NFC] Remove vector::__base_destruct_at_end (PR #217631)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Aug 25 01:23:42 PDT 2026
https://github.com/philnik777 updated https://github.com/llvm/llvm-project/pull/217631
>From 77bc98c79258e4b45258cf3432cc06fb6fccb5a7 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Thu, 20 Aug 2026 15:39:08 +0200
Subject: [PATCH] [libc++][NFC] Remove vector::__base_destruct_at_end
---
libcxx/include/__vector/vector.h | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/libcxx/include/__vector/vector.h b/libcxx/include/__vector/vector.h
index 5d2ef8fc2a583..fe1af60abcfe9 100644
--- a/libcxx/include/__vector/vector.h
+++ b/libcxx/include/__vector/vector.h
@@ -556,9 +556,7 @@ class _LIBCPP_WARN_UNUSED vector {
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last);
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT {
- size_type __old_size = size();
- __base_destruct_at_end(this->__layout_.__begin_ptr());
- __annotate_shrink(__old_size);
+ __destruct_at_end(__layout_.__begin_ptr());
}
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void resize(size_type __sz);
@@ -711,9 +709,11 @@ class _LIBCPP_WARN_UNUSED vector {
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign(vector& __c, false_type)
_NOEXCEPT_(__alloc_traits::is_always_equal::value);
+
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_end(pointer __new_last) _NOEXCEPT {
size_type __old_size = size();
- __base_destruct_at_end(__new_last);
+ std::__allocator_destroy(__layout_.__alloc(), __new_last, __layout_.__end_ptr());
+ __layout_.__set_bound_using_pointer(__new_last);
__annotate_shrink(__old_size);
}
@@ -770,13 +770,6 @@ class _LIBCPP_WARN_UNUSED vector {
_ConstructTransaction& operator=(_ConstructTransaction const&) = delete;
};
- _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __base_destruct_at_end(pointer __new_last) _NOEXCEPT {
- pointer __soon_to_be_end = __layout_.__end_ptr();
- while (__new_last != __soon_to_be_end)
- __alloc_traits::destroy(this->__layout_.__alloc(), std::__to_address(--__soon_to_be_end));
- __layout_.__set_bound_using_pointer(__new_last);
- }
-
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const vector& __c) {
__copy_assign_alloc(__c, integral_constant<bool, __alloc_traits::propagate_on_container_copy_assignment::value>());
}
More information about the libcxx-commits
mailing list