diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2013-06-03 18:41:08 +0100 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2013-06-03 18:41:08 +0100 |
commit | 1726304d72f766777c3e8f6a15f789fdaec5803e (patch) | |
tree | 79a630e4fe21dc0b96f9b8117347907ac6c09e4f /desktop | |
parent | dafe9a6208d4160daa9375c405fc637f1dbd3c6d (diff) | |
download | netsurf-1726304d72f766777c3e8f6a15f789fdaec5803e.tar.gz netsurf-1726304d72f766777c3e8f6a15f789fdaec5803e.tar.bz2 |
Simplify tree walker.
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/treeview.c | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/desktop/treeview.c b/desktop/treeview.c index 9d3dce54a..02dd7e208 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -573,34 +573,24 @@ static bool treeview_walk_internal(struct treeview_node *root, bool full, node->children : NULL; if (next != NULL) { - /* down to children */ + /* Down to children */ node = next; inset += tree_g.step_width; } else { - /* no children */ - next = node->sibling_next; - - if (next != NULL && node != root) { - /* on to next sibling */ - node = next; - } else { - /* no next sibling */ - while (node != root) { - next = node->sibling_next; - - if (next != NULL) { - break; - } - - node = node->parent; - inset -= tree_g.step_width; - } + /* No children. As long as we're not at the root, + * go to next sibling if present, or nearest ancestor + * with a next sibling. */ + + 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); |