From 599dee204ff9bc9cbaad75ec1d077a6e7d957c15 Mon Sep 17 00:00:00 2001 From: joaquintides Date: Mon, 17 Oct 2022 18:00:15 +0200 Subject: [PATCH] micro-optimized table destruction --- include/boost/unordered/detail/foa.hpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/include/boost/unordered/detail/foa.hpp b/include/boost/unordered/detail/foa.hpp index 90388f44..92bffb5d 100644 --- a/include/boost/unordered/detail/foa.hpp +++ b/include/boost/unordered/detail/foa.hpp @@ -1123,8 +1123,7 @@ public: }); } BOOST_CATCH(...){ - clear(); - delete_arrays(arrays); + destroy(); BOOST_RETHROW } BOOST_CATCH_END @@ -1153,9 +1152,8 @@ public: }); } BOOST_CATCH(...){ - clear(); - delete_arrays(arrays); x.clear(); + destroy(); BOOST_RETHROW } BOOST_CATCH_END @@ -1165,8 +1163,7 @@ public: ~table()noexcept { - clear(); - delete_arrays(arrays); + destroy(); } table& operator=(const table& x) @@ -1458,6 +1455,14 @@ private: Allocator& al(){return allocator_base::get();} const Allocator& al()const{return allocator_base::get();} + void destroy()noexcept + { + for_all_elements([this](value_type* p){ + destroy_element(p); + }); + delete_arrays(arrays); + } + arrays_type new_arrays(std::size_t n) { return arrays_type::new_(al(),n);