This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Subtle MT problem with __gnu_cxx::hash_map


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]