From c1317cb5bee0057712c31f52667b6c0852745c16 Mon Sep 17 00:00:00 2001 From: joaquintides Date: Fri, 3 May 2024 18:11:13 +0200 Subject: [PATCH] replaced get_cumulative_stats() with direct access to cstats --- .../unordered/detail/foa/concurrent_table.hpp | 14 +++++--------- include/boost/unordered/detail/foa/core.hpp | 14 ++++---------- include/boost/unordered/detail/foa/table.hpp | 3 +-- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/include/boost/unordered/detail/foa/concurrent_table.hpp b/include/boost/unordered/detail/foa/concurrent_table.hpp index cae13539c..8531fac9e 100644 --- a/include/boost/unordered/detail/foa/concurrent_table.hpp +++ b/include/boost/unordered/detail/foa/concurrent_table.hpp @@ -514,8 +514,7 @@ class concurrent_table: x.arrays=ah.release(); x.size_ctrl.ml=x.initial_max_load(); x.size_ctrl.size=0; - BOOST_UNORDERED_SWAP_STATS( - this->get_cumulative_stats(),x.get_cumulative_stats()); + BOOST_UNORDERED_SWAP_STATS(this->cstats,x.cstats); } concurrent_table(compatible_nonconcurrent_table&& x): @@ -1216,8 +1215,7 @@ class concurrent_table: if(BOOST_LIKELY(bool(this->pred()(x,this->key_from(p[n]))))){ f(pg,n,p+n); BOOST_UNORDERED_ADD_STATS( - this->get_cumulative_stats().successful_lookup, - (pb.length(),num_cmps)); + this->cstats.successful_lookup,(pb.length(),num_cmps)); return 1; } } @@ -1226,14 +1224,13 @@ class concurrent_table: } if(BOOST_LIKELY(pg->is_not_overflowed(hash))){ BOOST_UNORDERED_ADD_STATS( - this->get_cumulative_stats().unsuccessful_lookup, - (pb.length(),num_cmps)); + this->cstats.unsuccessful_lookup,(pb.length(),num_cmps)); return 0; } } while(BOOST_LIKELY(pb.next(this->arrays.groups_size_mask))); BOOST_UNORDERED_ADD_STATS( - this->get_cumulative_stats().unsuccessful_lookup,(pb.length(),num_cmps)); + this->cstats.unsuccessful_lookup,(pb.length(),num_cmps)); return 0; } @@ -1514,8 +1511,7 @@ class concurrent_table: this->construct_element(p,std::forward(args)...); rslot.commit(); rsize.commit(); - BOOST_UNORDERED_ADD_STATS( - this->get_cumulative_stats().insertion,(pb.length())); + BOOST_UNORDERED_ADD_STATS(this->cstats.insertion,(pb.length())); return 1; } pg->mark_overflow(hash); diff --git a/include/boost/unordered/detail/foa/core.hpp b/include/boost/unordered/detail/foa/core.hpp index ca69f7b32..ab2fb86c1 100644 --- a/include/boost/unordered/detail/foa/core.hpp +++ b/include/boost/unordered/detail/foa/core.hpp @@ -1719,7 +1719,7 @@ table_core:empty_value,empty_value,empty_value auto n=unchecked_countr_zero(mask); if(BOOST_LIKELY(bool(pred()(x,key_from(p[n]))))){ BOOST_UNORDERED_ADD_STATS( - get_cumulative_stats().successful_lookup,(pb.length(),num_cmps)); + cstats.successful_lookup,(pb.length(),num_cmps)); return {pg,n,p+n}; } mask&=mask-1; @@ -1727,13 +1727,13 @@ table_core:empty_value,empty_value,empty_value } if(BOOST_LIKELY(pg->is_not_overflowed(hash))){ BOOST_UNORDERED_ADD_STATS( - get_cumulative_stats().unsuccessful_lookup,(pb.length(),num_cmps)); + cstats.unsuccessful_lookup,(pb.length(),num_cmps)); return {}; } } while(BOOST_LIKELY(pb.next(arrays.groups_size_mask))); BOOST_UNORDERED_ADD_STATS( - get_cumulative_stats().unsuccessful_lookup,(pb.length(),num_cmps)); + cstats.unsuccessful_lookup,(pb.length(),num_cmps)); return {}; } @@ -1842,11 +1842,6 @@ table_core:empty_value,empty_value,empty_value }; } - cumulative_stats& get_cumulative_stats()const noexcept - { - return cstats; - } - void reset_stats() { cstats.insertion.reset(); @@ -2356,8 +2351,7 @@ table_core:empty_value,empty_value,empty_value auto p=arrays_.elements()+pos*N+n; construct_element(p,std::forward(args)...); pg->set(n,hash); - BOOST_UNORDERED_ADD_STATS( - get_cumulative_stats().insertion,(pb.length())); + BOOST_UNORDERED_ADD_STATS(cstats.insertion,(pb.length())); return {pg,n,p}; } else pg->mark_overflow(hash); diff --git a/include/boost/unordered/detail/foa/table.hpp b/include/boost/unordered/detail/foa/table.hpp index cf96e6226..529a514cd 100644 --- a/include/boost/unordered/detail/foa/table.hpp +++ b/include/boost/unordered/detail/foa/table.hpp @@ -593,8 +593,7 @@ class table:table_core_impl x.arrays=ah.release(); x.size_ctrl.ml=x.initial_max_load(); x.size_ctrl.size=0; - BOOST_UNORDERED_SWAP_STATS( - this->get_cumulative_stats(),x.get_cumulative_stats()); + BOOST_UNORDERED_SWAP_STATS(this->cstats,x.cstats); } template