|
Boost : |
From: Daniel James (daniel_james_at_[hidden])
Date: 2008-01-03 10:12:30
On 03/01/2008, Thorsten Ottosen <thorsten.ottosen_at_[hidden]> wrote:
>
> Can boost::compressed_pair not be used to remove the overhead of
> stateless functors and hashers?
I used to do that but I found that in practice the difference was so
slight it didn't seem worth it. If you have 4 zero-sized function
objects (2 hash functions, 2 equality functions), it's the difference
between 1 or 2 bytes and 4 bytes. Which often doesn't make a
difference because of padding.
The pointer to the current pair of objects (typically 4 bytes) is
where the real cost lies. I could possibly use a different
implementation for empty objects so that the pointer isn't required,
but I'm not sure about the technicalities or if it would be worth the
extra complexity. I could also use a bool instead of a pointer but
that has costs elsewhere (I haven't measured this, so I'm not entirely
sure how expensive it would be).
It might be worth using compressed_pair (or something similar) for
allocators, but I never got round to doing that.
I've generally not been that concerned about the size of the container
object, as it tends to be small compared to the memory required for
the buckets and nodes.
Daniel
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk