From 2e776ad155538de3469543176dc05bfbb3e375a9 Mon Sep 17 00:00:00 2001 From: joaquintides Date: Wed, 28 Sep 2022 17:53:58 +0200 Subject: [PATCH] fixed clear --- include/boost/unordered/detail/foa.hpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/include/boost/unordered/detail/foa.hpp b/include/boost/unordered/detail/foa.hpp index 26123e37..822b49ac 100644 --- a/include/boost/unordered/detail/foa.hpp +++ b/include/boost/unordered/detail/foa.hpp @@ -755,7 +755,20 @@ public: void clear()noexcept { - for_all_elements([this](value_type* p){destroy_element(p);}); + auto pg=arrays.groups; + auto p=arrays.elements; + if(p){ + for(std::size_t pos=0,last=arrays.groups_size_mask+1; + pos!=last;++pos,++pg,p+=N){ + auto mask=pg->match_really_occupied(); + while(mask){ + auto n=unchecked_countr_zero(mask); + destroy_element(p+n); + pg->reset(n); + mask&=mask-1; + } + } + } size_=0; }