Skip to content

Conversation

@philnik777
Copy link
Contributor

No description provided.

@philnik777 philnik777 marked this pull request as ready for review November 11, 2024 22:32
@philnik777 philnik777 requested a review from a team as a code owner November 11, 2024 22:32
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Nov 11, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 11, 2024

@llvm/pr-subscribers-libcxx

Author: Nikolas Klauser (philnik777)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/115735.diff

1 Files Affected:

  • (modified) libcxx/include/__split_buffer (-23)
diff --git a/libcxx/include/__split_buffer b/libcxx/include/__split_buffer
index 2a2f2625c748b2..63ead9b1efd36d 100644
--- a/libcxx/include/__split_buffer
+++ b/libcxx/include/__split_buffer
@@ -139,7 +139,6 @@ public:
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference back() { return *(__end_ - 1); }
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference back() const { return *(__end_ - 1); }
 
-  _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n);
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT;
 
   template <class... _Args>
@@ -153,9 +152,6 @@ public:
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n);
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n, const_reference __x);
 
-  template <class _InputIter, __enable_if_t<__has_exactly_input_iterator_category<_InputIter>::value, int> = 0>
-  _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(_InputIter __first, _InputIter __last);
-
   template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
   __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
@@ -260,13 +256,6 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_referen
   }
 }
 
-template <class _Tp, class _Allocator>
-template <class _InputIter, __enable_if_t<__has_exactly_input_iterator_category<_InputIter>::value, int> >
-_LIBCPP_CONSTEXPR_SINCE_CXX20 void
-__split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last) {
-  __construct_at_end_with_sentinel(__first, __last);
-}
-
 template <class _Tp, class _Allocator>
 template <class _Iterator, class _Sentinel>
 _LIBCPP_CONSTEXPR_SINCE_CXX20 void
@@ -414,18 +403,6 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::swap(__split
   std::__swap_allocator(__alloc_, __x.__alloc_);
 }
 
-template <class _Tp, class _Allocator>
-_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::reserve(size_type __n) {
-  if (__n < capacity()) {
-    __split_buffer<value_type, __alloc_rr&> __t(__n, 0, __alloc_);
-    __t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_));
-    std::swap(__first_, __t.__first_);
-    std::swap(__begin_, __t.__begin_);
-    std::swap(__end_, __t.__end_);
-    std::swap(__end_cap_, __t.__end_cap_);
-  }
-}
-
 template <class _Tp, class _Allocator>
 _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT {
   if (capacity() > size()) {

Copy link
Member

@ldionne ldionne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you validate that these methods are unused by e.g. adding a static assertion in them? LGTM if they are truly unused.

I know that std::deque uses this as an implementation detail for mapping segments. Would we benefit from calling reserve in some cases in that implementation?

@philnik777
Copy link
Contributor Author

Can you validate that these methods are unused by e.g. adding a static assertion in them? LGTM if they are truly unused.

I know that std::deque uses this as an implementation detail for mapping segments. Would we benefit from calling reserve in some cases in that implementation?

I've checked manually and couldn't find any references. If there is a use-case for reserve in deque we can still implement a working version later (the current one is actually broken).

@philnik777 philnik777 merged commit 36fa8bd into llvm:main Nov 12, 2024
65 checks passed
@philnik777 philnik777 deleted the simplify_split_buffer branch November 12, 2024 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants