Boost logo

Boost :

From: Dave Harris (brangdon_at_[hidden])
Date: 2005-06-24 19:12:12


In-Reply-To: <42BBC406.1A3FB240_at_[hidden]>
joaquin_at_[hidden] (=?iso-8859-1?Q?Joaqu=EDn=20M=AA=20L=F3pez=20Mu=F1oz?=)
wrote (abridged):
> The hardest part is checking for equality. My proposal is
> to follow a hash-based approach, which is effective both in
> terms of complexity and space (one word per tracked object.),
> and does not impose any special requirement on the serialized
> objects (for instance, an approach based on operator== would
> require that objects be equalitycomparable).
> [...]
> if(hash_addr!=0){
> boost::hash_combine(*hash_addr,x);
> }

Why do we need the test against 0? Is it supposed to improve performance?
Hashing ought to be cheap - it is just bit-twiddling on primitives - and
conditional branches are relatively expensive. It may be quicker to always
hash.

It might be worth using #ifndef _NDEBUG or similar, though.

-- Dave Harris, Nottingham, UK.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk