Turn this function into a StackFunction.
authorSoeren Sandmann <sandmann@redhat.com>
Sun, 6 Nov 2005 22:10:30 +0000 (22:10 +0000)
committerSøren Sandmann Pedersen <ssp@src.gnome.org>
Sun, 6 Nov 2005 22:10:30 +0000 (22:10 +0000)
Sun Nov  6 17:06:52 2005  Soeren Sandmann  <sandmann@redhat.com>

        * profile.c (add_trace_to_tree): Turn this function into a
        StackFunction.

        * stackstash.c (stack_node_foreach_trace): Make this function take
        a StackFunction, and reimplement with do_callback().

ChangeLog
profile.c
stackstash.c
stackstash.h
sysprof.c

index fe18595..586885d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Sun Nov  6 17:06:52 2005  Soeren Sandmann  <sandmann@redhat.com>
+
+       * profile.c (add_trace_to_tree): Turn this function into a
+       StackFunction. 
+
+       * stackstash.c (stack_node_foreach_trace): Make this function take
+       a StackFunction, and reimplement with do_callback().
+
 Sat Nov  5 18:06:40 2005  Soeren Sandmann  <sandmann@redhat.com>
 
        * profile.c (profile_create_descendants): Use callbacks from
index af58187..c3eb982 100644 (file)
--- a/profile.c
+++ b/profile.c
 
 typedef struct Node Node;
 
-static void
-update()
-{
-#if 0
-    while (g_main_pending())
-       g_main_iteration (FALSE);
-#endif
-}
-
 struct Profile
 {
     StackStash *       stash;
@@ -243,27 +234,24 @@ profile_new (StackStash *stash)
 }
 
 static void
-add_trace_to_tree (GSList *trace, gpointer data)
+add_trace_to_tree (GSList *trace, gint size, gpointer data)
 {
     GSList *list;
     GPtrArray *nodes_to_unmark = g_ptr_array_new ();
     ProfileDescendant *parent = NULL;
     int i, len;
     ProfileDescendant **tree = data;
-    guint size = ((StackNode *)trace->data)->size;
 
     trace = g_slist_reverse (g_slist_copy (trace));
 
     for (list = trace; list != NULL; list = list->next)
     {
-       StackNode *node = list->data;
+       gpointer address = list->data;
        ProfileDescendant *match = NULL;
 
-       update();
-       
        for (match = *tree; match != NULL; match = match->siblings)
        {
-           if (match->name == node->address)
+           if (match->name == address)
                break;
        }
        
@@ -276,7 +264,7 @@ add_trace_to_tree (GSList *trace, gpointer data)
            seen_tree_node = NULL;
            for (n = parent; n != NULL; n = n->parent)
            {
-               if (n->name == node->address)
+               if (n->name == address)
                    seen_tree_node = n;
            }
            
@@ -300,7 +288,7 @@ add_trace_to_tree (GSList *trace, gpointer data)
        {
            match = g_new (ProfileDescendant, 1);
            
-           match->name = node->address;
+           match->name = address;
            match->non_recursion = 0;
            match->self = 0;
            match->children = NULL;
index af82f50..1a4c7d3 100644 (file)
@@ -61,7 +61,6 @@ decorate_node (StackStash *stash,
     /* FIXME: we will probably want to do this lazily,
      * and more efficiently (only walk the tree once).
      */
-
     for (n = node->parent; n != NULL; n = n->parent)
     {
        if (n->address == node->address)
@@ -128,23 +127,23 @@ stack_stash_add_trace (StackStash *stash,
 
 static void
 do_callback (StackNode *node,
-            GSList    *trace,
-            StackFunction stack_func,
+            const GSList *trace,
+            StackFunction func,
             gpointer data)
 {
     GSList link;
-    
+
     if (!node)
        return;
 
-    link.next = trace;
+    link.next = (GSList *)trace;
     link.data = node->address;
-    
-    do_callback (node->siblings, trace, stack_func, data);
-    do_callback (node->children, &link, stack_func, data);
 
     if (node->size)
-       stack_func (&link, node->size, data);
+       func (&link, node->size, data);
+    
+    do_callback (node->children, &link, func, data);
+    do_callback (node->siblings, trace, func, data);
 }
 
 void
@@ -155,40 +154,20 @@ stack_stash_foreach   (StackStash      *stash,
     do_callback (stash->root, NULL, stack_func, data);
 }
 
-static void
-do_node_callback (StackNode *node, const GSList *trace,
-                 StackTraceFunction func,
-                 gpointer data)
-{
-    GSList link;
-
-    if (!node)
-       return;
-
-    link.next = (GSList *)trace;
-    link.data = node;
-
-    if (node->size)
-       func (&link, data);
-    
-    do_node_callback (node->children, &link, func, data);
-    do_node_callback (node->siblings, trace, func, data);
-}
-
 void
-stack_node_foreach_trace (StackNode *node,
-                         StackTraceFunction func,
-                         gpointer   data)
+stack_node_foreach_trace (StackNode     *node,
+                         StackFunction  func,
+                         gpointer       data)
 {
     GSList link;
 
     link.next = NULL;
-    link.data = node;
+    link.data = node->address;
 
     if (node->size)
-       func (&link, data);
+       func (&link, node->size, data);
     
-    do_node_callback (node->children, &link, func, data);
+    do_callback (node->children, &link, func, data);
 }
 
 static void
index 1a5ce6c..0bd8909 100644 (file)
@@ -54,16 +54,14 @@ void        stack_stash_add_trace (StackStash      *stash,
 void        stack_stash_foreach   (StackStash      *stash,
                                   StackFunction    stack_func,
                                   gpointer         data);
+void       stack_node_foreach_trace (StackNode *node,
+                                     StackFunction stack_func,
+                                     gpointer      data);
 StackNode  *stack_stash_find_node (StackStash      *stash,
                                   gpointer         address);
 /* FIXME: should probably return a list */
 void       stack_node_list_leaves (StackNode  *node,
                                    GList     **leaves);
-typedef void (* StackTraceFunction) (GSList *trace, gpointer data);
-void       stack_node_foreach_trace (StackNode *node,
-                                     StackTraceFunction func,
-                                     gpointer   data);
-
 typedef void (* StackNodeFunc) (StackNode *node,
                                gpointer data);
 void       stack_stash_foreach_by_address (StackStash *stash,
index c787778..7a0359b 100644 (file)
--- a/sysprof.c
+++ b/sysprof.c
@@ -1003,7 +1003,7 @@ on_object_selection_changed (GtkTreeSelection *selection,
 
     set_busy (app->main_window, TRUE);
 
-    gdk_window_process_all_updates ();
+    gdk_window_process_all_updates (); /* Display updated selection */
     
     fill_descendants_tree (app);
     fill_callers_list (app);