From ca59ed8c500a7d8b38bbc6b600383d0462eea0c8 Mon Sep 17 00:00:00 2001 From: joaquintides Date: Thu, 16 Mar 2023 10:44:01 +0100 Subject: [PATCH] avoided usage of match_really_occupied on for_all_elements_while (used by rehash) --- include/boost/unordered/detail/foa/core.hpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/include/boost/unordered/detail/foa/core.hpp b/include/boost/unordered/detail/foa/core.hpp index 79e49ae4..8de09173 100644 --- a/include/boost/unordered/detail/foa/core.hpp +++ b/include/boost/unordered/detail/foa/core.hpp @@ -1634,6 +1634,7 @@ public: static auto for_all_elements_while(const arrays_type& arrays_,F f) ->decltype(f(nullptr,0,nullptr),void()) { +#if 0 auto p=arrays_.elements; if(!p){return;} for(auto pg=arrays_.groups,last=pg+arrays_.groups_size_mask+1; @@ -1645,6 +1646,26 @@ public: mask&=mask-1; } } +#else + auto p=arrays_.elements; + if(!p){return;} + auto pg=arrays_.groups; + for(auto last=pg+arrays_.groups_size_mask; + pg!=last;++pg,p+=N){ + auto mask=pg->match_occupied(); + while(mask){ + auto n=unchecked_countr_zero(mask); + if(!f(pg,n,p+n))return; + mask&=mask-1; + } + } + auto mask=pg->match_really_occupied(); + while(mask){ + auto n=unchecked_countr_zero(mask); + if(!f(pg,n,p+n))return; + mask&=mask-1; + } +#endif } arrays_type arrays;