Tom Lane wrote:

Gaetano Mendola <[EMAIL PROTECTED]> writes:

[ use list with master node and circular linking ]


now is very late here ( 04:17 AM ) so I wrote
the wrong code ( not checked ) but show the idea of
avoid "if".



This saves an "if" during addition of a list item, at the cost of
greater expense during list traversal.  (Instead of a loop termination
test like "ptr != NULL", you need something like "ptr != master_node".
This may not take an extra cycle, but only if you can afford to dedicate
a register to holding the value of master_node within the loop.  That
hurts, especially on architectures with not very many registers.)


Well, if the same architecture have not so many register I guess don't
have a double prefetch instruction queue and an "if" branch
will hurt/destroy that queue, am I wrong ?

I'm going to post on comp.lang.c++.moderated and
comp.std.c++ in order to have better argumentations



Anyway, we should build the code that way and then do profiling with and
without support for constant-cost length().

I totally agree with you.



Regards Gaetano Mendola


---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Reply via email to