[gtk/wip/otte/for-master: 4/6] treerbtree: Use for loops



commit c0568a01097aaefbc38d6f6d2f82a0677b52ac5f
Author: Benjamin Otte <otte redhat com>
Date:   Thu Mar 5 06:58:44 2020 +0100

    treerbtree: Use for loops
    
    Makes the code more readable.
    Also does the NULL check for the initial element, which was misisng
    before.

 gtk/gtktreerbtree.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)
---
diff --git a/gtk/gtktreerbtree.c b/gtk/gtktreerbtree.c
index 964b6026d1..3331d0a5cc 100644
--- a/gtk/gtktreerbtree.c
+++ b/gtk/gtktreerbtree.c
@@ -722,9 +722,9 @@ gtk_tree_rbtree_column_invalid (GtkTreeRBTree *tree)
   if (tree == NULL)
     return;
 
-  node = gtk_tree_rbtree_first (tree);
-
-  do
+  for (node = gtk_tree_rbtree_first (tree);
+       node != NULL;
+       node = gtk_tree_rbtree_next (tree, node))
     {
       if (!(GTK_TREE_RBNODE_FLAG_SET (node, GTK_TREE_RBNODE_INVALID)))
         GTK_TREE_RBNODE_SET_FLAG (node, GTK_TREE_RBNODE_COLUMN_INVALID);
@@ -733,7 +733,6 @@ gtk_tree_rbtree_column_invalid (GtkTreeRBTree *tree)
       if (node->children)
         gtk_tree_rbtree_column_invalid (node->children);
     }
-  while ((node = gtk_tree_rbtree_next (tree, node)) != NULL);
 }
 
 void
@@ -744,9 +743,9 @@ gtk_tree_rbtree_mark_invalid (GtkTreeRBTree *tree)
   if (tree == NULL)
     return;
 
-  node = gtk_tree_rbtree_first (tree);
-
-  do
+  for (node = gtk_tree_rbtree_first (tree);
+       node != NULL;
+       node = gtk_tree_rbtree_next (tree, node))
     {
       GTK_TREE_RBNODE_SET_FLAG (node, GTK_TREE_RBNODE_INVALID);
       GTK_TREE_RBNODE_SET_FLAG (node, GTK_TREE_RBNODE_DESCENDANTS_INVALID);
@@ -754,7 +753,6 @@ gtk_tree_rbtree_mark_invalid (GtkTreeRBTree *tree)
       if (node->children)
         gtk_tree_rbtree_mark_invalid (node->children);
     }
-  while ((node = gtk_tree_rbtree_next (tree, node)) != NULL);
 }
 
 void
@@ -767,9 +765,9 @@ gtk_tree_rbtree_set_fixed_height (GtkTreeRBTree *tree,
   if (tree == NULL)
     return;
 
-  node = gtk_tree_rbtree_first (tree);
-
-  do
+  for (node = gtk_tree_rbtree_first (tree);
+       node != NULL;
+       node = gtk_tree_rbtree_next (tree, node))
     {
       if (GTK_TREE_RBNODE_FLAG_SET (node, GTK_TREE_RBNODE_INVALID))
         {
@@ -781,7 +779,6 @@ gtk_tree_rbtree_set_fixed_height (GtkTreeRBTree *tree,
       if (node->children)
         gtk_tree_rbtree_set_fixed_height (node->children, height, mark_valid);
     }
-  while ((node = gtk_tree_rbtree_next (tree, node)) != NULL);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]