Subtle MT problem with __gnu_cxx::hash_map

Paolo Carlini pcarlini@suse.de
Tue Nov 23 15:50:00 GMT 2004


Paul Dubuc wrote:

> The call to resize() actually doubles the capacity of the container.  
> If it's not going to do in insert, this is a tremendous waste of 
> memory and overhead. Especially with a hash_map since all existing 
> elements have to be rehashed.  On these grounds alone, it's worth 
> making the simple one line change I originally proposed.  The resize() 
> shouldn't be done until the container has done the find() and finds 
> nothing.  Then it should be done before the insert.

Hi everyone and sorry if I jump in only now...

Well, frankly, everything considered, I'm with Paul. I mean, **provided 
we don't claim in the docs any additional guarantee about the behavior 
of operator[]** what's wrong with delaying the reallocation to when it's 
actually necessary?

Maybe this is the last chance to tweak the aged extension hashed 
containers... ;)

Paolo.



More information about the Libstdc++ mailing list