hash policy patch

François Dumont francois.cppdevs@free.fr
Thu Jul 28 20:46:00 GMT 2011


On 07/26/2011 10:15 PM, Paolo Carlini wrote:
> Hi,
>> Hi
>>
>>     Here is an other patch proposal to refactor some code in hash 
>> policy implementation
> This bit I had yesterday in my local tree and made me nervous because 
> __min_bkts is a float: std::lower_bound is templatized on the third 
> argument, thus in principle the refactoring isn't really equivalent. 
> Can we prove it is, given the actual values of __min_bkts?
     I forget to talk about this modification. Yes with this refactoring 
the float value is casted to size_t before the call to lower_bound. 
There is no modification here because when the float value is casted to 
size_t we lose only the decimal part but not the integer part. As the 
research is done on integer values only the integer part of __min_bkts 
is important. Even if __min_bkts is greater than size_t max value then 
the cast will always give this size_t mas value and the call to 
lower_bound will always give the larger prime number from the list of 
prime numbers.

     This is in fact even a good side effect of this patch, lower_bound 
will only be instantiated once with the size_t value.

>
> Give me a second for the other hunks. In any case, if we'll come to 
> agree about the substance of the issue, I think we should factor out 
> the try / catch to a function, no? I see three identical instances of 
> the same code...
>
> Paolo.
>
     In fact I will submit an other patch for this part because I found 
several other situations where max_load_factor is not respected because 
hash policy _M_next_resize is not correctly maintained. I should submit 
a patch by this WE.

François



More information about the Libstdc++ mailing list