Re: [boost] [serialization] a proposal for an alternative to the new c

In-Reply-To: <42BBC406.1A3FB240@tid.es> joaquin@tid.es (=?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.
participants (1)
-
brangdon@cix.compulink.co.uk