swapped stats on move construction/assignment

This commit is contained in:
joaquintides 2024-05-01 18:11:01 +02:00
parent d01ae76074
commit e588e04a1b

View File

@ -1161,12 +1161,16 @@ struct table_core_stats
};
#define BOOST_UNORDERED_ADD_STATS(stats,args) stats.add args
#define BOOST_UNORDERED_SWAP_STATS(stats1,stats2) std::swap(stats1,stats2)
#define BOOST_UNORDERED_RESET_STATS_OF(x) x.reset_stats()
#define BOOST_UNORDERED_STATS_COUNTER(name) std::size_t name=0
#define BOOST_UNORDERED_INCREMENT_STATS_COUNTER(name) ++name
#else
#define BOOST_UNORDERED_ADD_STATS(stats,args) ((void)0)
#define BOOST_UNORDERED_SWAP_STATS(stats1,stats2) ((void)0)
#define BOOST_UNORDERED_RESET_STATS_OF(x) ((void)0)
#define BOOST_UNORDERED_STATS_COUNTER(name) ((void)0)
#define BOOST_UNORDERED_INCREMENT_STATS_COUNTER(name) ((void)0)
@ -1481,6 +1485,7 @@ public:
x.arrays=ah.release();
x.size_ctrl.ml=x.initial_max_load();
x.size_ctrl.size=0;
BOOST_UNORDERED_SWAP_STATS(cstats,x.cstats);
}
table_core(table_core&& x)
@ -1506,11 +1511,13 @@ public:
using std::swap;
swap(arrays,x.arrays);
swap(size_ctrl,x.size_ctrl);
BOOST_UNORDERED_SWAP_STATS(cstats,x.cstats);
}
else{
reserve(x.size());
clear_on_exit c{x};
(void)c; /* unused var warning */
BOOST_UNORDERED_RESET_STATS_OF(x);
/* This works because subsequent x.clear() does not depend on the
* elements' values.