================
@@ -431,52 +599,61 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, 
_Allocator>::shrink_to_fi
 template <class _Tp, class _Allocator>
 template <class... _Args>
 _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, 
_Allocator>::emplace_front(_Args&&... __args) {
-  if (__begin_ == __first_) {
-    if (__end_ < __cap_) {
-      difference_type __d = __cap_ - __end_;
+  if (__data_.__begin_ == __data_.__first_) {
+    pointer __end = __data_.end();
+    if (__data_.__front_spare() != 0) {
+      difference_type __d = __data_.__back_spare();
       __d                 = (__d + 1) / 2;
-      __begin_            = std::move_backward(__begin_, __end_, __end_ + __d);
-      __end_ += __d;
+      __data_.__begin_    = std::move_backward(__data_.__begin_, __end, __end 
+ __d);
+#ifdef _LIBCPP_ABI_SIZE_BASED_CONTAINERS
+      // TODO: explain why there isn't a size-based analogue
+#else
+      __data_.__end_ += __d;
+#endif
     } else {
-      size_type __c = std::max<size_type>(2 * static_cast<size_type>(__cap_ - 
__first_), 1);
-      __split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, 
__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(__cap_, __t.__cap_);
+      size_type __c = std::max<size_type>(2 * capacity(), 1);
+      __split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, 
__data_.__alloc_);
+      __t.__construct_at_end(move_iterator<pointer>(__data_.__begin_), 
move_iterator<pointer>(__end));
+      __data_.__swap_without_allocator(__t.__data_);
     }
   }
-  __alloc_traits::construct(__alloc_, std::__to_address(__begin_ - 1), 
std::forward<_Args>(__args)...);
-  --__begin_;
+
+  __alloc_traits::construct(__data_.__alloc_, 
std::__to_address(__data_.__begin_ - 1), std::forward<_Args>(__args)...);
+  --__data_.__begin_;
+#ifdef _LIBCPP_ABI_SIZE_BASED_CONTAINERS
+  __data_.__update_sentinel(__data_.end() + 1);
+#else
+  // TODO: explain why there isn't a pointer-based analogue
+#endif
 }
 
-template <class _Tp, class _Allocator>
-template <class... _Args>
+template<class _Tp, class _Allocator>
+template<class... _Args>
 _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, 
_Allocator>::emplace_back(_Args&&... __args) {
-  if (__end_ == __cap_) {
-    if (__begin_ > __first_) {
-      difference_type __d = __begin_ - __first_;
+  pointer __end = __data_.end();
+  if (__data_.__back_spare() == 0) {
+    if (__data_.__begin_ > __data_.__first_) {
+      difference_type __d = __data_.__begin_ - __data_.__first_;
----------------
ldionne wrote:

```suggestion
    if (__data_.__front_spare() > 0) {
      difference_type __d = __data_.__front_spare();
```

https://github.com/llvm/llvm-project/pull/139632
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to