diff options
-rw-r--r-- | src/tree.c | 32 |
1 files changed, 12 insertions, 20 deletions
@@ -151,32 +151,28 @@ static gboolean foreach(MqTree *node, gboolean (*cb)(MqTree *node, gpointer user_data), gpointer user_data) { - gboolean ret; - - ret = MQ_TREE_CONTINUE; for (; node; node = node->next) { /* XXX: Warning: Does not skip root node */ - ret = cb(node, user_data); - if (ret == MQ_TREE_STOP) { - break; + if (cb(node, user_data) == MQ_TREE_STOP) { + return MQ_TREE_STOP; } if (node->first_child) { - ret = foreach(node->first_child, cb, user_data); - if (ret == MQ_TREE_STOP) { - break; + if (foreach(node->first_child, cb, user_data) == + MQ_TREE_STOP) { + return MQ_TREE_STOP; } } if (node->parent && node->parent->next) { - ret = foreach(node->parent->next, cb, user_data); - if (ret == MQ_TREE_STOP) { - break; + if (foreach(node->parent->next, cb, user_data) == + MQ_TREE_STOP) { + return MQ_TREE_STOP; } } } - return ret; + return MQ_TREE_CONTINUE; } void @@ -190,17 +186,13 @@ static gboolean foreach_child(MqTree *node, gboolean (*cb)(MqTree *node, gpointer user_data), gpointer user_data) { - gboolean ret; - - ret = MQ_TREE_CONTINUE; for (node = node->first_child; node; node = node->next) { - ret = cb(node, user_data); - if (ret == MQ_TREE_STOP) { - break; + if (cb(node, user_data) == MQ_TREE_STOP) { + return MQ_TREE_STOP; } } - return ret; + return MQ_TREE_CONTINUE; } void |