From cc97853b5f03e8c8441159e68ecb2262beee166f Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 26 Nov 2024 09:05:48 -0800 Subject: Fix ArenaVector::swap (#7115) This was never right for over a decade, and just never used I suppose... it should have been called "take" since it grabbed data from the other item and then set that other item to empty. Fix it so it swaps properly. --- src/mixed_arena.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mixed_arena.h b/src/mixed_arena.h index 530fa9daa..057887b82 100644 --- a/src/mixed_arena.h +++ b/src/mixed_arena.h @@ -263,12 +263,9 @@ public: void operator=(SubType& other) { set(other); } void swap(SubType& other) { - data = other.data; - usedElements = other.usedElements; - allocatedElements = other.allocatedElements; - - other.data = nullptr; - other.usedElements = other.allocatedElements = 0; + std::swap(data, other.data); + std::swap(usedElements, other.usedElements); + std::swap(allocatedElements, other.allocatedElements); } // iteration -- cgit v1.2.3