This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Annoying warning
- To: jbuck at Synopsys dot COM (Joe Buck)
- Subject: Re: Annoying warning
- From: Carlo Wood <carlo at runaway dot xs4all dot nl>
- Date: Mon, 12 Apr 1999 16:22:19 +0200 (CEST)
- Cc: egcs at cygnus dot com
| It would be better to either remove the 'inline' or to rewrite the
| function into a form that can be inlined (tail recursion):
|
| inline int __black_count(__rb_tree_node_base* node, __rb_tree_node_base* root,
| int black_parent)
| {
| if (node == 0)
| return black_parent;
| else {
| int bc = (node->color == __rb_tree_black);
| if (node == root)
| return bc + black_parent;
| else
| return __black_count(node->parent, root, bc);
| }
| }
I think need to return __black_count(node->parent, root, bc + black_parent) there.
On the other hand, it doesn't seem to increase readability to me.
I'd get rid of the recursion completely and write something like this:
inline int __black_count(__rb_tree_node_base* node, __rb_tree_node_base* root)
{
int count = 0;
for (; node; node = node->parent)
{
if (node->color == __rb_tree_black)
++count;
if (node == root)
break;
}
return count;
}
Perhaps you can forward this to the maintainers of the STL egcs is using?
--
Carlo Wood <carlo@runaway.xs4all.nl>