From d233d838114634d38e183d1d32feaccc2528e42a Mon Sep 17 00:00:00 2001 From: joaquintides Date: Wed, 5 Oct 2022 14:49:42 +0200 Subject: [PATCH] allow 100% fillup for small capacities --- include/boost/unordered/detail/foa.hpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/include/boost/unordered/detail/foa.hpp b/include/boost/unordered/detail/foa.hpp index 1744798a..1777da49 100644 --- a/include/boost/unordered/detail/foa.hpp +++ b/include/boost/unordered/detail/foa.hpp @@ -1195,10 +1195,15 @@ private: std::size_t max_load()const { - float fml=mlf*(float)(capacity()); - auto res=(std::numeric_limits::max)(); - if(res>(std::size_t)fml)res=(std::size_t)fml; - return res; + static constexpr std::size_t small_capacity=2*N-1; + + auto capacity_=capacity(); + if(capacity_<=small_capacity){ + return capacity_; /* we allow 100% usage */ + } + else{ + return (std::size_t)(mlf*(float)(capacity_)); + } } static inline auto key_from(const value_type& x)