[Dcmlib] std::map vs std::hash_map

Sean McInerney seanm at nmr.mgh.harvard.edu
Thu Jul 7 05:27:48 CEST 2005


Mathieu Malaterre wrote:
> 
> 
> 
> Just for reference I recently saw a thread (which I cannot find at the
> moment), where somebody is working on enhancing the hash when using
> string. The only reference I could find is:
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21193
> 
> The thread must be in gcc, on June or July 2005, but the search engine
> does not seems to work...
> 
> Mathieu
> 
Hi Mathieu,

For strings that are allocated and deallocated at lot, one can create a
small object allocator and pass it as a template parameter to
basic_string<>. Such an allocator would allocate memory for strings out
of a pool of chunks ... thereby reducing heap thrashing.

But I don't think that would buy much in GDCM's case ... your strings
get allocated and then just sit there in the map ... so I think I'm back
to getting clever with the hash function ... hmmmmmmmm

If the maps are bottlenecks, you could use a lean and mean non-STL hash
map ... but you lose all the safety and convenience of using the STL.
Unless you really need the speed, I'm starting to think that it might
not be worth the price of an overly ad hoc solution.

BTW ... I hope that I'm helping more than complicating the issue.

Ciao

-Sean



More information about the Dcmlib mailing list