Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Fri, 05 Feb 2016 01:27:22 UTC Commit: 1ddf952d3a4c1998d18e788b901f0e72177ec337 https://github.com/geany/geany-plugins/commit/1ddf952d3a4c1998d18e788b901f0e...
Log Message: ----------- debugger: Speed up building several lists
Prepend elements to GLists and reverse them afterward when possible, as GLists have very bad append performances as it walks the entire list to find the end, where to insert the new element.
Modified Paths: -------------- debugger/src/breakpoints.c debugger/src/dbm_gdb.c debugger/src/debug.c debugger/src/envtree.c debugger/src/watch_model.c
Modified: debugger/src/breakpoints.c 6 lines changed, 3 insertions(+), 3 deletions(-) =================================================================== @@ -70,7 +70,7 @@ static void hash_table_foreach_call_function(gpointer key, gpointer value, gpoin static gboolean tree_foreach_add_to_list(gpointer key, gpointer value, gpointer data) { GList **list = (GList**)data; - *list = g_list_append(*list, value); + *list = g_list_prepend(*list, value); return FALSE; }
@@ -675,7 +675,7 @@ GList* breaks_get_for_document(const char* file) { g_tree_foreach(tree, tree_foreach_add_to_list, &breaks); } - return breaks; + return g_list_reverse(breaks); }
/* @@ -702,5 +702,5 @@ GList* breaks_get_all(void) { GList *breaks = NULL; g_hash_table_foreach(files, hash_table_foreach_add_to_list, &breaks); - return breaks; + return g_list_reverse(breaks); }
Modified: debugger/src/dbm_gdb.c 14 lines changed, 8 insertions(+), 6 deletions(-) =================================================================== @@ -213,10 +213,10 @@ static GList* read_until_prompt(void) break;
line[terminator] = '\0'; - lines = g_list_append (lines, line); + lines = g_list_prepend (lines, line); } - return lines; + return g_list_reverse(lines); }
/* @@ -1129,11 +1129,11 @@ static GList* get_stack(void) /* line */ f->line = line ? atoi(line) : 0;
- stack = g_list_append(stack, f); + stack = g_list_prepend(stack, f); } gdb_mi_record_free(record); - return stack; + return g_list_reverse(stack); }
/* @@ -1293,8 +1293,9 @@ static void update_watches(void) var->evaluated = name != NULL;
/* add to updating list */ - updating = g_list_append(updating, var); + updating = g_list_prepend(updating, var); } + updating = g_list_reverse(updating); /* update watches */ get_variables(updating); @@ -1465,11 +1466,12 @@ static GList* get_children (gchar* path) var = variable_new2(name, internal, VT_CHILD); var->evaluated = TRUE;
- children = g_list_append(children, var); + children = g_list_prepend(children, var); } } gdb_mi_record_free(record); + children = g_list_reverse(children); get_variables(children);
return children;
Modified: debugger/src/debug.c 8 lines changed, 4 insertions(+), 4 deletions(-) =================================================================== @@ -418,13 +418,13 @@ static gboolean on_watch_key_pressed_callback(GtkWidget *widget, GdkEvent *even
/* add path reference if it's not an empty row*/ if (gtk_tree_path_compare(path, empty_path)) - references = g_list_append(references, gtk_tree_row_reference_new(wmodel, path)); + references = g_list_prepend(references, gtk_tree_row_reference_new(wmodel, path));
iter = iter->next; }
/* iterate through references and remove */ - iter = references; + iter = g_list_reverse(references); while (iter) { GtkTreeRowReference *reference = (GtkTreeRowReference*)iter->data; @@ -1126,11 +1126,11 @@ GList* debug_get_modules(void) module_description *desc = modules; while (desc->title) { - mods = g_list_append(mods, (gpointer)desc->title); + mods = g_list_prepend(mods, (gpointer)desc->title); desc++; } - return mods; + return g_list_reverse(mods); }
/*
Modified: debugger/src/envtree.c 4 lines changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -135,7 +135,7 @@ static void delete_selected_rows(void) } if (gtk_tree_path_compare(path, empty_path)) - references = g_list_append(references, gtk_tree_row_reference_new(model, path)); + references = g_list_prepend(references, gtk_tree_row_reference_new(model, path)); iter = iter->next; } @@ -145,7 +145,7 @@ static void delete_selected_rows(void) if (!reference_to_select) reference_to_select = gtk_tree_row_reference_copy (empty_row);
- iter = references; + iter = g_list_reverse(references); while (iter) { GtkTreeIter titer;
Modified: debugger/src/watch_model.c 4 lines changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -476,9 +476,9 @@ GList *get_root_items(GtkTreeView *tree) -1); if (strlen(name)) - names = g_list_append(names, name); + names = g_list_prepend(names, name); } while (gtk_tree_model_iter_next(model, &child)); - return names; + return g_list_reverse(names); }
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
plugins-commits@lists.geany.org