perf hists browser: replace rb_first() != NULL by !RB_EMPTY_ROOT()

Its way too stupid to use rb_first() for just caching if there are
children, use the cheaper RB_EMPTY_ROOT() instead.

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
LKML-Reference: <new-submission>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 18b308d7
...@@ -129,16 +129,16 @@ static void callchain_node__init_have_children_rb_tree(struct callchain_node *se ...@@ -129,16 +129,16 @@ static void callchain_node__init_have_children_rb_tree(struct callchain_node *se
for (nd = rb_first(&self->rb_root); nd; nd = rb_next(nd)) { for (nd = rb_first(&self->rb_root); nd; nd = rb_next(nd)) {
struct callchain_node *child = rb_entry(nd, struct callchain_node, rb_node); struct callchain_node *child = rb_entry(nd, struct callchain_node, rb_node);
struct callchain_list *chain; struct callchain_list *chain;
int first = true; bool first = true;
list_for_each_entry(chain, &child->val, list) { list_for_each_entry(chain, &child->val, list) {
if (first) { if (first) {
first = false; first = false;
chain->ms.has_children = chain->list.next != &child->val || chain->ms.has_children = chain->list.next != &child->val ||
rb_first(&child->rb_root) != NULL; !RB_EMPTY_ROOT(&child->rb_root);
} else } else
chain->ms.has_children = chain->list.next == &child->val && chain->ms.has_children = chain->list.next == &child->val &&
rb_first(&child->rb_root) != NULL; !RB_EMPTY_ROOT(&child->rb_root);
} }
callchain_node__init_have_children_rb_tree(child); callchain_node__init_have_children_rb_tree(child);
...@@ -150,7 +150,7 @@ static void callchain_node__init_have_children(struct callchain_node *self) ...@@ -150,7 +150,7 @@ static void callchain_node__init_have_children(struct callchain_node *self)
struct callchain_list *chain; struct callchain_list *chain;
list_for_each_entry(chain, &self->val, list) list_for_each_entry(chain, &self->val, list)
chain->ms.has_children = rb_first(&self->rb_root) != NULL; chain->ms.has_children = !RB_EMPTY_ROOT(&self->rb_root);
callchain_node__init_have_children_rb_tree(self); callchain_node__init_have_children_rb_tree(self);
} }
...@@ -301,11 +301,11 @@ static int hist_browser__show_callchain_node_rb_tree(struct hist_browser *self, ...@@ -301,11 +301,11 @@ static int hist_browser__show_callchain_node_rb_tree(struct hist_browser *self,
if (first) { if (first) {
first = false; first = false;
chain->ms.has_children = chain->list.next != &child->val || chain->ms.has_children = chain->list.next != &child->val ||
rb_first(&child->rb_root) != NULL; !RB_EMPTY_ROOT(&child->rb_root);
} else { } else {
extra_offset = LEVEL_OFFSET_STEP; extra_offset = LEVEL_OFFSET_STEP;
chain->ms.has_children = chain->list.next == &child->val && chain->ms.has_children = chain->list.next == &child->val &&
rb_first(&child->rb_root) != NULL; !RB_EMPTY_ROOT(&child->rb_root);
} }
folded_sign = callchain_list__folded(chain); folded_sign = callchain_list__folded(chain);
...@@ -381,7 +381,7 @@ static int hist_browser__show_callchain_node(struct hist_browser *self, ...@@ -381,7 +381,7 @@ static int hist_browser__show_callchain_node(struct hist_browser *self,
* probably when the callchain is created, so as not to * probably when the callchain is created, so as not to
* traverse it all over again * traverse it all over again
*/ */
chain->ms.has_children = rb_first(&node->rb_root) != NULL; chain->ms.has_children = !RB_EMPTY_ROOT(&node->rb_root);
folded_sign = callchain_list__folded(chain); folded_sign = callchain_list__folded(chain);
if (*row_offset != 0) { if (*row_offset != 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment