mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
Move match to front (add_trace_to_tree): Break as soon as a recursive call
2006-11-22 Soren Sandmann <sandmann@daimi.au.dk> * profile.c (add_trace_to_tree): Move match to front (add_trace_to_tree): Break as soon as a recursive call is found. * stackstash.c (do_callback): Manual tail call optimization.
This commit is contained in:
committed by
Søren Sandmann Pedersen
parent
d1a082ffec
commit
d3c0e7be5c
21
profile.c
21
profile.c
@ -256,20 +256,30 @@ add_trace_to_tree (GList *trace, gint size, gpointer data)
|
||||
GList *list;
|
||||
ProfileDescendant *parent = NULL;
|
||||
int i, len;
|
||||
ProfileDescendant **tree = data;
|
||||
|
||||
ProfileDescendant **tree = data;
|
||||
|
||||
if (!nodes_to_unmark)
|
||||
nodes_to_unmark = g_ptr_array_new ();
|
||||
|
||||
|
||||
for (list = g_list_last (trace); list != NULL; list = list->prev)
|
||||
{
|
||||
gpointer address = list->data;
|
||||
ProfileDescendant *match = NULL;
|
||||
ProfileDescendant *prev = NULL;
|
||||
|
||||
for (match = *tree; match != NULL; match = match->siblings)
|
||||
for (match = *tree; match != NULL; prev = match, match = match->siblings)
|
||||
{
|
||||
if (match->name == address)
|
||||
{
|
||||
if (prev)
|
||||
{
|
||||
/* Move to front */
|
||||
prev->siblings = match->siblings;
|
||||
match->siblings = *tree;
|
||||
*tree = match;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!match)
|
||||
@ -282,7 +292,10 @@ add_trace_to_tree (GList *trace, gint size, gpointer data)
|
||||
for (n = parent; n != NULL; n = n->parent)
|
||||
{
|
||||
if (n->name == address)
|
||||
{
|
||||
seen_tree_node = n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (seen_tree_node)
|
||||
|
||||
Reference in New Issue
Block a user