diff options
Diffstat (limited to 'widgets/table/e-tree-model.c')
-rw-r--r-- | widgets/table/e-tree-model.c | 65 |
1 files changed, 30 insertions, 35 deletions
diff --git a/widgets/table/e-tree-model.c b/widgets/table/e-tree-model.c index d90088624f..ed15f28f8c 100644 --- a/widgets/table/e-tree-model.c +++ b/widgets/table/e-tree-model.c @@ -967,21 +967,21 @@ e_tree_model_node_real_traverse (ETreeModel *model, ETreePath path, ETreePath en child = e_tree_model_node_get_last_child (model, path); while (child) { - ETreePath next_child; ETreePath result; - if (child == end_path || func (model, child, data)) + if (forward_direction && (child == end_path || func (model, child, data))) return child; - if (forward_direction) - next_child = e_tree_model_node_get_next (model, child); - else - next_child = e_tree_model_node_get_prev (model, child); - if ((result = e_tree_model_node_real_traverse (model, child, end_path, forward_direction, func, data))) return result; - child = next_child; + if (!forward_direction && (child == end_path || func (model, child, data))) + return child; + + if (forward_direction) + child = e_tree_model_node_get_next (model, child); + else + child = e_tree_model_node_get_prev (model, child); } return NULL; } @@ -1021,39 +1021,34 @@ e_tree_model_node_find (ETreeModel *model, ETreePath path, ETreePath end_path, g return NULL; } - start: - - if (forward_direction) { - if ((result = e_tree_model_node_real_traverse (model, path, end_path, forward_direction, func, data))) - return result; - next = e_tree_model_node_get_next (model, path); - } else { - next = e_tree_model_node_get_prev (model, path); - if (next && (result = e_tree_model_node_real_traverse (model, next, end_path, forward_direction, func, data))) - return result; - } + while (1) { - if (next) { - if (end_path == next || func (model, next, data)) - return next; + if (forward_direction) { + if ((result = e_tree_model_node_real_traverse (model, path, end_path, forward_direction, func, data))) + return result; + next = e_tree_model_node_get_next (model, path); + } else { + next = e_tree_model_node_get_prev (model, path); + if (next && (result = e_tree_model_node_real_traverse (model, next, end_path, forward_direction, func, data))) + return result; + } - /* return e_tree_model_node_find (model, next, end_path, forward_direction, func, data) */ - path = next; - goto start; - } + while (next == NULL) { + path = e_tree_model_node_get_parent (model, path); - path = e_tree_model_node_get_parent (model, path); + if (path == NULL) + return NULL; - if (path && forward_direction) - path = e_tree_model_node_get_next (model, path); + if (forward_direction) + next = e_tree_model_node_get_next (model, path); + else + next = path; + } - if (path) { - if (end_path == path || func (model, path, data)) - return path; + if (end_path == next || func (model, next, data)) + return next; - /* return e_tree_model_node_find (model, path, end_path, forward_direction, func, data) */ - goto start; + path = next; } - return NULL; } |