[libcxx-commits] [libcxx] [libcxx] Optimize __split_buffer::__relocate by using size-based __set_valid_range (PR #216822)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Oct 21 16:46:36 PDT 2026
https://github.com/ldionne updated https://github.com/llvm/llvm-project/pull/216822
>From 901706d2efc97ec8eca0aaa5666608d1b4b84f62 Mon Sep 17 00:00:00 2001
From: Liza Burakova <liza at chromium.org>
Date: Thu, 3 Sep 2026 18:26:19 +0000
Subject: [PATCH 1/2] [libcxx] Optimize __split_buffer::__relocate by using
size-based __set_valid_range
---
libcxx/include/__split_buffer | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libcxx/include/__split_buffer b/libcxx/include/__split_buffer
index d89264186d77e..b2bf4c84dd737 100644
--- a/libcxx/include/__split_buffer
+++ b/libcxx/include/__split_buffer
@@ -416,7 +416,8 @@ public:
auto __last = __first + __n;
std::__uninitialized_allocator_relocate(
__alloc_, std::__to_address(__first), std::__to_address(__last), std::__to_address(__new_begin));
- __set_valid_range(__new_begin, end());
+ __set_valid_range(__new_begin, __n);
+
__n = 0;
__swap_layouts(__first, __n, __capacity);
>From 5698c9b59610dc474c42bf2dd3cf564215718141 Mon Sep 17 00:00:00 2001
From: Liza Burakova <liza at chromium.org>
Date: Tue, 15 Sep 2026 22:01:35 +0000
Subject: [PATCH 2/2] fix calculation for __set_valid_range call
---
libcxx/include/__split_buffer | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/include/__split_buffer b/libcxx/include/__split_buffer
index b2bf4c84dd737..e66c755313aae 100644
--- a/libcxx/include/__split_buffer
+++ b/libcxx/include/__split_buffer
@@ -416,7 +416,7 @@ public:
auto __last = __first + __n;
std::__uninitialized_allocator_relocate(
__alloc_, std::__to_address(__first), std::__to_address(__last), std::__to_address(__new_begin));
- __set_valid_range(__new_begin, __n);
+ __set_valid_range(__new_begin, __size_ + __n);
__n = 0;
More information about the libcxx-commits
mailing list