[gedit] theatrics: use foreach_remove instead of foreach and call remove inside



commit 4a06b52019e58fda3450f9563ef2ce889110534c
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Mon Jun 13 15:37:22 2011 +0200

    theatrics: use foreach_remove instead of foreach and call remove inside

 gedit/theatrics/gedit-theatrics-stage.c |   13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)
---
diff --git a/gedit/theatrics/gedit-theatrics-stage.c b/gedit/theatrics/gedit-theatrics-stage.c
index 7d76e44..5520e95 100644
--- a/gedit/theatrics/gedit-theatrics-stage.c
+++ b/gedit/theatrics/gedit-theatrics-stage.c
@@ -177,7 +177,7 @@ gedit_theatrics_stage_init (GeditTheatricsStage *stage)
 						g_direct_equal);
 }
 
-static void
+static gboolean
 iterate_actors (gpointer             key,
 		gpointer             value,
 		GeditTheatricsStage *stage)
@@ -188,10 +188,7 @@ iterate_actors (gpointer             key,
 
 	g_signal_emit (G_OBJECT (stage), signals[ACTOR_STEP], 0, actor);
 
-	if (gedit_theatrics_actor_get_expired (actor))
-	{
-		g_hash_table_remove (stage->priv->actors, key);
-	}
+	return gedit_theatrics_actor_get_expired (actor);
 }
 
 static gboolean
@@ -203,9 +200,9 @@ on_timeout (GeditTheatricsStage *stage)
 		return FALSE;
 	}
 
-	g_hash_table_foreach (stage->priv->actors,
-			      (GHFunc)iterate_actors,
-			      stage);
+	g_hash_table_foreach_remove (stage->priv->actors,
+	                             (GHRFunc)iterate_actors,
+	                             stage);
 
 	g_signal_emit (G_OBJECT (stage), signals[ITERATION], 0);
 



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