[sldev] LLUUIDHashMap vs hash_map
Dale Glass
dale at daleglass.net
Thu Sep 20 05:52:36 PDT 2007
On Thu, Sep 20, 2007 at 01:20:48PM +0200, Dale Glass wrote:
> I'm looking at implementing a cache storing data by LLUUID and found the
> LLUUIDHashMap. I see it seems to be used only in LLMotionRegistry.
>
> Should I use it? How about making a hash function for LLUUID and using
> that instead? I presume that simply using the first/last
> sizeof(size_t)*8 bits of the LLUUID would work fine.
Been looking a bit more at the source of LLUUIDHashMap, it's weird.
It's hardcoded to 256 buckets, not even as a constant but as a magic
number in the source (ick!)
It uses an U8 for the hash key, so it can't go higher anyway.
LLUUIDHashNode stores a number of elements that varies depending on the
argument to the template (why?)
So I'm thinking a hash_map could be better for my purposes, as I might
want more than 256 elements (cache will probably be quite big).
For the hash function I'm considering this:
size_t operator()(const LLUUID&x)
{
return (size_t)x.getCRC32();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.secondlife.com/pipermail/sldev/attachments/20070920/6caf97a3/attachment.pgp
More information about the SLDev
mailing list