Author: fejj
Date: 2007-12-03 17:05:28 -0500 (Mon, 03 Dec 2007)
New Revision: 90601

Modified:
   trunk/moon/src/ChangeLog
   trunk/moon/src/clock.cpp
Log:
2007-12-03  Jeffrey Stedfast  <[EMAIL PROTECTED]>

        * clock.cpp (RaiseEnqueuedEvents): Optimized a bit by not
        iterating thru the list 6 times :)



Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog    2007-12-03 21:48:51 UTC (rev 90600)
+++ trunk/moon/src/ChangeLog    2007-12-03 22:05:28 UTC (rev 90601)
@@ -1,3 +1,8 @@
+2007-12-03  Jeffrey Stedfast  <[EMAIL PROTECTED]>
+
+       * clock.cpp (RaiseEnqueuedEvents): Optimized a bit by not
+       iterating thru the list 6 times :)
+
 2007-12-03  Larry Ewing  <[EMAIL PROTECTED]>
 
        * media.cpp (Image::Render): remove accumulated drawing cruft.

Modified: trunk/moon/src/clock.cpp
===================================================================
--- trunk/moon/src/clock.cpp    2007-12-03 21:48:51 UTC (rev 90600)
+++ trunk/moon/src/clock.cpp    2007-12-03 22:05:28 UTC (rev 90601)
@@ -251,7 +251,7 @@
 void
 TimeManager::tick_callback (EventObject *sender, gpointer calldata, gpointer 
closure)
 {
-       ((TimeManager*)closure)->Tick ();
+       ((TimeManager *) closure)->Tick ();
 }
 
 void
@@ -380,17 +380,36 @@
        last_global_time = current_global_time;
 }
 
+typedef struct ClockNode {
+       struct ClockNode *next;
+       Clock *clock;
+} ClockNode;
+
 void
 TimeManager::RaiseEnqueuedEvents ()
 {
-       GList *copy = g_list_copy (child_clocks);
-       g_list_foreach (copy, (GFunc)base_ref, NULL);
-       for (GList *l = copy; l; l = l->next) {
-               Clock *c = (Clock*)l->data;
-               c->RaiseAccumulatedEvents ();
+       ClockNode *list, *tail, *next;
+       GList *n;
+       
+       list = NULL;
+       tail = (ClockNode *) &list;
+       
+       for (n = child_clocks; n != NULL; n = n->next) {
+               tail->next = g_new (ClockNode, 1);
+               tail = tail->next;
+               
+               tail->clock = (Clock *) n->data;
+               tail->clock->ref ();
+               tail->next = NULL;
        }
-       g_list_foreach (copy, (GFunc)base_unref, NULL);
-       g_list_free (copy);
+       
+       while (list != NULL) {
+               list->clock->RaiseAccumulatedEvents ();
+               list->clock->unref ();
+               next = list->next;
+               g_free (list);
+               list = next;
+       }
 }
 
 guint
@@ -1089,7 +1108,7 @@
        GList *next;
        
        while (node != NULL) {
-               Clock *clock = (Clock*)node->data;
+               Clock *clock = (Clock *) node->data;
                clock->SetParent (NULL);
                clock->unref ();
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to