diff options
author | Christopher James Lahey <clahey@ximian.com> | 2002-02-01 04:23:00 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2002-02-01 04:23:00 +0800 |
commit | a3bd2634b10cbeaa0dd82cdb37c9007476977050 (patch) | |
tree | 5a55e4d3945578c19e5483c9aa9c4cd8a9491d83 /widgets/table/e-tree-model.c | |
parent | 81762a26a3409b65c1d7a45e024eaba88242f103 (diff) | |
download | gsoc2013-evolution-a3bd2634b10cbeaa0dd82cdb37c9007476977050.tar gsoc2013-evolution-a3bd2634b10cbeaa0dd82cdb37c9007476977050.tar.gz gsoc2013-evolution-a3bd2634b10cbeaa0dd82cdb37c9007476977050.tar.bz2 gsoc2013-evolution-a3bd2634b10cbeaa0dd82cdb37c9007476977050.tar.lz gsoc2013-evolution-a3bd2634b10cbeaa0dd82cdb37c9007476977050.tar.xz gsoc2013-evolution-a3bd2634b10cbeaa0dd82cdb37c9007476977050.tar.zst gsoc2013-evolution-a3bd2634b10cbeaa0dd82cdb37c9007476977050.zip |
Made this function much more readable. Got rid of all the gotos. Fixed a
2002-01-31 Christopher James Lahey <clahey@ximian.com>
* e-tree-model.c (e_tree_model_node_find): Made this function much
more readable. Got rid of all the gotos. Fixed a case where
going backwards during a root search checked the root node first.
(e_tree_model_node_real_traverse): Made backwards traversals be
postorder, as they should be, instead of preorder.
* e-tree.c (find_next_callback): Use an extra callback function
here to go from sorted path to model path.
svn path=/trunk/; revision=15543
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; } |