tr1::hashtable::operator[]
Paolo Carlini
pcarlini@suse.de
Sun May 14 23:10:00 GMT 2006
Paolo Carlini wrote:
> Joe Buck wrote:
>
>> There is wasted work because of the two lookups, but perhaps there's
>> a way to further improve the situation by exposing the common part
>> of find() and insert(), namely the hash computation. If there were
>> a way to do the find(), and somehow reuse the hash computed by the
>> find() to do the insert() more quickly, then I think Peter's approach
>> would be an even bigger win.
>
> Definitely. That is exactly my point.
... and the below is a preview of my implementation of your (Joe's and
Peter's) very helpful suggestions. As you can see, in a nutshell the
idea is implementing insert with hint and calling it from operator[] (as
per our std::map). In this case the hint is "special", we are not
passing a regular iterator, because we have to convey somehow the info
that the element is not present yet and in which bucket it will be
inserted (assuming no rehashing occurs).
As-is the patch (*) already passes regtesting and a few additional
simple tests, it would be nice if Peter could benchmark it, while I
refine it to its final (hoepfully cleaner) shape...
Thanks,
Paolo.
(*) It includes trivial clean-ups, otherwise would be much smaller.
//////////////////
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch_tr1_insert_draft
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20060514/a425abca/attachment.ksh>
More information about the Libstdc++
mailing list