From 088d60ec9662d2ecc34410fbaf6a7ff05c9e5558 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 3 Jun 2013 18:54:19 +0100 Subject: Simplify redraw node walk. --- desktop/treeview.c | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/desktop/treeview.c b/desktop/treeview.c index dfa4ea3a1..812b3b330 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -796,29 +796,20 @@ void treeview_redraw(struct treeview *tree, int x, int y, struct rect *clip, node = next; inset += tree_g.step_width; } else { - /* no children */ - next = node->sibling_next; - - if (next != NULL) { - /* on to next sibling */ - node = next; - } else { - /* no next sibling */ - while (node != root) { - next = node->sibling_next; + /* No children. As long as we're not at the root, + * go to next sibling if present, or nearest ancestor + * with a next sibling. */ - if (next != NULL) { - break; - } - node = node->parent; - inset -= tree_g.step_width; - } + while (node != root && + node->sibling_next == NULL) { + node = node->parent; + inset -= tree_g.step_width; + } - if (node == root) - break; + if (node == root) + break; - node = node->sibling_next; - } + node = node->sibling_next; } assert(node != NULL); -- cgit v1.2.3