This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: needless deep recursion in gt-c-decl.h
Geoff Keating wrote:
From: Per Bothner <per@bothner.com>
Specifically, we should iterate, not recurse, on the
field that is most likely to be a long list, the TREE_CHAIN.
It's not as simple as that, because there'll often be a reference to
the TREE_CHAIN from inside the node.
I don't know what this sentence means. If you mean that some node
referenced by one of the other (non-chain) fields (possibly indirectly)
is the same node as the chain, I don't see how that's complicates it.
However, yes, you can do
something like this. In fact, I tried it in the hope that it would
make GC faster; it didn't (but it didn't make it much slower either).
Did it make it slower at all? It would be strange if iteration is
slower than recursion (unless that just happens to hit the cache better,
which would surprise me). If interation is the same speed or faster,
we should use it, to reduce running out of stack space.
--
--Per Bothner
per@bothner.com http://www.bothner.com/per/