[prev in list] [next in list] [prev in thread] [next in thread]
List: gcc
Subject: Re: Annoying warning
From: Carlo Wood <carlo () runaway ! xs4all ! nl>
Date: 1999-04-12 14:22:19
[Download RAW message or body]
| 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>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic