From 3a34b8dae9d35113f4c5eb49023ac6fa7c44a31e Mon Sep 17 00:00:00 2001 From: joaquintides Date: Mon, 28 Nov 2022 12:13:04 +0100 Subject: [PATCH] micro-optimized previous --- include/boost/unordered/detail/foa.hpp | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/include/boost/unordered/detail/foa.hpp b/include/boost/unordered/detail/foa.hpp index 8a74a0ac..01e3ba34 100644 --- a/include/boost/unordered/detail/foa.hpp +++ b/include/boost/unordered/detail/foa.hpp @@ -689,46 +689,39 @@ struct pow2_size_policy // of performance std::size_t used_bits_=n<=2?1:((std::size_t)(boost::core::bit_width(n-1))); - std::size_t used_mask_=(std::size_t(1)<=10?(5-(used_bits_%6))*2:0; - std::size_t used_lo_=used_bits_-used_hi_; + std::size_t used_hi_mask_=(std::size_t(1)<>=unused_bits_; - return ((hash>>used_lo_)|(hash<>unused_bits_)&~used_hi_mask_)|(hash&used_hi_mask_); } private: static constexpr std::size_t total_bits=sizeof(std::size_t)*CHAR_BIT; - static inline std::size_t used_mask(std::size_t size_index_) + static inline std::size_t used_hi_mask(std::size_t size_index_) { - return size_index_>>24; + return size_index_>>16; } static inline std::size_t used_hi(std::size_t size_index_) - { - return (size_index_>>16)&0xffu; - } - - static inline std::size_t used_lo(std::size_t size_index_) { return (size_index_>>8)&0xffu; }