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

Hello Dave, ----- Mensaje original ----- De: brangdon@cix.compulink.co.uk (Dave Harris) Fecha: Sábado, Junio 25, 2005 2:37 am Asunto: 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.
Well, the proposed pseudocode is only meant to illustrate the idea, certainly it could prove faster to hash unconditionally.
It might be worth using #ifndef _NDEBUG or similar, though.
Yes. As this is merely a protection against incorrect user code, one should be able to turn it on/off or at least have it only in debug mode, much in the same way as the safety checks done by some STL implementations. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
participants (1)
-
JOAQUIN LOPEZ MU?Z