]> Pileus Git - ~andy/gtk/commitdiff
quit maintaining the iter on every iteration, only get the iter when we
authorKristian Rietveld <kris@gtk.org>
Tue, 12 Jul 2005 23:01:17 +0000 (23:01 +0000)
committerKristian Rietveld <kristian@src.gnome.org>
Tue, 12 Jul 2005 23:01:17 +0000 (23:01 +0000)
2005-07-13  Kristian Rietveld  <kris@gtk.org>

* gtk/gtktreeselection.c (gtk_tree_selection_selected_foreach): quit
maintaining the iter on every iteration, only get the iter when
we are about to call the foreach_func. Gives us a 10x speedup,
since maintaining iters is a lot more expensive than maintaining
paths. We lose a bit of sanity checking though. Thanks go to
Billy Biggs for pointing this out.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-8
gtk/gtktreeselection.c

index ff9e419d5ce312aa230371ddf483f76018ca34c8..b4e55c2e41dc92d48044071293bb53a3186bd792 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2005-07-13  Kristian Rietveld  <kris@gtk.org>
+
+       * gtk/gtktreeselection.c (gtk_tree_selection_selected_foreach): quit
+       maintaining the iter on every iteration, only get the iter when
+       we are about to call the foreach_func. Gives us a 10x speedup,
+       since maintaining iters is a lot more expensive than maintaining
+       paths. We lose a bit of sanity checking though. Thanks go to
+       Billy Biggs for pointing this out.
+
 2005-07-12  Matthias Clasen  <mclasen@redhat.com>
 
        * tests/testcairo.c (draw): Fix the same confusion here, too.
index ff9e419d5ce312aa230371ddf483f76018ca34c8..b4e55c2e41dc92d48044071293bb53a3186bd792 100644 (file)
@@ -1,3 +1,12 @@
+2005-07-13  Kristian Rietveld  <kris@gtk.org>
+
+       * gtk/gtktreeselection.c (gtk_tree_selection_selected_foreach): quit
+       maintaining the iter on every iteration, only get the iter when
+       we are about to call the foreach_func. Gives us a 10x speedup,
+       since maintaining iters is a lot more expensive than maintaining
+       paths. We lose a bit of sanity checking though. Thanks go to
+       Billy Biggs for pointing this out.
+
 2005-07-12  Matthias Clasen  <mclasen@redhat.com>
 
        * tests/testcairo.c (draw): Fix the same confusion here, too.
index ff9e419d5ce312aa230371ddf483f76018ca34c8..b4e55c2e41dc92d48044071293bb53a3186bd792 100644 (file)
@@ -1,3 +1,12 @@
+2005-07-13  Kristian Rietveld  <kris@gtk.org>
+
+       * gtk/gtktreeselection.c (gtk_tree_selection_selected_foreach): quit
+       maintaining the iter on every iteration, only get the iter when
+       we are about to call the foreach_func. Gives us a 10x speedup,
+       since maintaining iters is a lot more expensive than maintaining
+       paths. We lose a bit of sanity checking though. Thanks go to
+       Billy Biggs for pointing this out.
+
 2005-07-12  Matthias Clasen  <mclasen@redhat.com>
 
        * tests/testcairo.c (draw): Fix the same confusion here, too.
index 3b9d686e471ea849b226d1dd49c35cd12689c217..676a221771a70b783a60af653be1b23d4d32a0dc 100644 (file)
@@ -620,7 +620,7 @@ gtk_tree_selection_selected_foreach (GtkTreeSelection            *selection,
   GtkTreeIter iter;
 
   guint inserted_id, deleted_id, reordered_id;
-  gboolean stop = FALSE, has_next = TRUE, has_parent = TRUE;
+  gboolean stop = FALSE;
 
   g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
   g_return_if_fail (selection->tree_view != NULL);
@@ -665,59 +665,46 @@ gtk_tree_selection_selected_foreach (GtkTreeSelection            *selection,
 
   /* find the node internally */
   path = gtk_tree_path_new_first ();
-  gtk_tree_model_get_iter (selection->tree_view->priv->model,
-                          &iter, path);
 
   do
     {
       if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
-       (* func) (selection->tree_view->priv->model, path, &iter, data);
+        {
+          gtk_tree_model_get_iter (selection->tree_view->priv->model,
+                                   &iter, path);
+         (* func) (selection->tree_view->priv->model, path, &iter, data);
+        }
 
       if (stop)
        goto out;
 
       if (node->children)
        {
-         gboolean has_child;
-         GtkTreeIter tmp;
-
          tree = node->children;
          node = tree->root;
+
          while (node->left != tree->nil)
            node = node->left;
-         tmp = iter;
-         has_child = gtk_tree_model_iter_children (selection->tree_view->priv->model, &iter, &tmp);
-         gtk_tree_path_append_index (path, 0);
 
-         /* we do the sanity check at the bottom of this function */
-         if (!has_child)
-           goto out;
+         gtk_tree_path_append_index (path, 0);
        }
       else
        {
          gboolean done = FALSE;
+
          do
            {
              node = _gtk_rbtree_next (tree, node);
              if (node != NULL)
                {
-                 gboolean has_next;
-
-                 has_next = gtk_tree_model_iter_next (selection->tree_view->priv->model, &iter);
                  done = TRUE;
                  gtk_tree_path_next (path);
-
-                 /* we do the sanity check at the bottom of this function */
-                 if (!has_next)
-                   goto out;
                }
              else
                {
-                 gboolean has_parent;
-                 GtkTreeIter tmp_iter = iter;
-
                  node = tree->parent_node;
                  tree = tree->parent_tree;
+
                  if (tree == NULL)
                    {
                      /* we've run out of tree */
@@ -726,12 +713,7 @@ gtk_tree_selection_selected_foreach (GtkTreeSelection            *selection,
                      goto out;
                    }
 
-                 has_parent = gtk_tree_model_iter_parent (selection->tree_view->priv->model, &iter, &tmp_iter);
                  gtk_tree_path_up (path);
-
-                 /* we do the sanity check at the bottom of this function */
-                 if (!has_parent)
-                   goto out;
                }
            }
          while (!done);
@@ -751,10 +733,6 @@ out:
                                reordered_id);
 
   /* check if we have to spew a scary message */
-  if (!has_next)
-    TREE_VIEW_INTERNAL_ASSERT_VOID (has_next);
-  if (!has_parent)
-    TREE_VIEW_INTERNAL_ASSERT_VOID (has_parent);
   if (stop)
     g_warning
       ("The model has been modified from within gtk_tree_selection_selected_foreach.\n"