Branch: refs/heads/master
Author: Colomban Wendling <ban(a)herbesfolles.org>
Committer: Colomban Wendling <ban(a)herbesfolles.org>
Date: Sun, 07 Feb 2016 03:35:36 UTC
Commit: 77563203d6eb0cea464a4b1745e368360e6d89fb
https://github.com/geany/geany-plugins/commit/77563203d6eb0cea464a4b1745e36…
Log Message:
-----------
debugger/gdb_mi: Improve implementation of parse_cstring()
Copy blocks as long as possible at once instead of byte by byte, e.g.
everything between two escape sequences at once.
This gives a speedup of about 8% on typical data with few escape
sequences.
Modified Paths:
--------------
debugger/src/gdb_mi.c
Modified: debugger/src/gdb_mi.c
10 lines changed, 8 insertions(+), 2 deletions(-)
===================================================================
@@ -98,13 +98,17 @@ static gchar *parse_cstring(const gchar **p)
if (**p == '"')
{
+ const gchar *base;
+
(*p)++;
+ base = *p;
while (**p != '"')
{
gchar c = **p;
/* TODO: check expansions here */
if (c == '\\')
{
+ g_string_append_len(str, base, (*p) - base);
(*p)++;
c = **p;
switch (g_ascii_tolower(c))
@@ -159,12 +163,14 @@ static gchar *parse_cstring(const gchar **p)
}
break;
}
+ g_string_append_c(str, c);
+ base = (*p) + 1;
}
- if (**p == '\0')
+ else if (**p == '\0')
break;
- g_string_append_c(str, c);
(*p)++;
}
+ g_string_append_len(str, base, (*p) - base);
if (**p == '"')
(*p)++;
}
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
Branch: refs/heads/master
Author: Colomban Wendling <ban(a)herbesfolles.org>
Committer: Colomban Wendling <ban(a)herbesfolles.org>
Date: Sun, 07 Feb 2016 03:35:36 UTC
Commit: 95133ee30874e100ddc641289f164eb4c9d0734b
https://github.com/geany/geany-plugins/commit/95133ee30874e100ddc641289f164…
Log Message:
-----------
debugger/gdb_mi: Do not allocate values when reading invalid input
Only allocate a value structure in parse_value() if the input actually
contains a readable value, instead of destroying it if it doesn't.
This is particularly useful as the implementation of parse_value()
itself recurses in order to discriminate a value from a result, which
means that a value would be allocated and freed immediately for each
result in the input.
This gives a speedup of about 10% on typical data.
Modified Paths:
--------------
debugger/src/gdb_mi.c
Modified: debugger/src/gdb_mi.c
9 lines changed, 3 insertions(+), 6 deletions(-)
===================================================================
@@ -211,15 +211,17 @@ static gboolean parse_result(struct gdb_mi_result *result, const gchar **p)
* Actually, this is more permissive and allows mixed tuples/lists */
static struct gdb_mi_value *parse_value(const gchar **p)
{
- struct gdb_mi_value *val = g_malloc0(sizeof *val);
+ struct gdb_mi_value *val = NULL;
if (**p == '"')
{
+ val = g_malloc0(sizeof *val);
val->type = GDB_MI_VAL_STRING;
val->string = parse_cstring(p);
}
else if (**p == '{' || **p == '[')
{
struct gdb_mi_result *prev = NULL;
+ val = g_malloc0(sizeof *val);
val->type = GDB_MI_VAL_LIST;
gchar end = **p == '{' ? '}' : ']';
(*p)++;
@@ -248,11 +250,6 @@ static struct gdb_mi_value *parse_value(const gchar **p)
if (**p == end)
(*p)++;
}
- else
- {
- gdb_mi_value_free(val);
- val = NULL;
- }
return val;
}
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
Branch: refs/heads/master
Author: Colomban Wendling <ban(a)herbesfolles.org>
Committer: Colomban Wendling <ban(a)herbesfolles.org>
Date: Sun, 07 Feb 2016 03:32:58 UTC
Commit: 297be8db19e805238e8962c75aa2d74bf3cd8bbf
https://github.com/geany/geany-plugins/commit/297be8db19e805238e8962c75aa2d…
Log Message:
-----------
debugger: Greatly improve Stack Tree population speed
Appending elements to a TreeStore is very slow, while prepending them
is fast. As we add all items at once, prepend elements in reverse
order, which is a lot faster and does the same.
This leads to tremendous speedups with large stack traces.
For example, showing a 105000 frames height trace (resulting from
infinite recursion and thus stack exhaustion) used to take more than
105s, while it now takes less than 0.3s.
Modified Paths:
--------------
debugger/src/debug.c
debugger/src/stree.c
debugger/src/stree.h
Modified: debugger/src/debug.c
6 lines changed, 1 insertions(+), 5 deletions(-)
===================================================================
@@ -700,11 +700,7 @@ static void on_debugger_stopped (int thread_id)
/* get current stack trace and put in the tree view */
stack = active_module->get_stack();
- for (iter = stack; iter; iter = iter->next)
- {
- frame *f = (frame*)iter->data;
- stree_add(f);
- }
+ stree_add (stack);
stree_select_first_frame(TRUE);
/* files */
Modified: debugger/src/stree.c
19 lines changed, 14 insertions(+), 5 deletions(-)
===================================================================
@@ -430,20 +430,29 @@ GtkWidget* stree_init(move_to_line_cb ml, select_frame_cb sf)
}
/*
- * add frame to the tree view
+ * add frames to the tree view
*/
-void stree_add(frame *f)
+void stree_add(GList *frames)
{
+ GList *item;
GtkTreeRowReference *reference = (GtkTreeRowReference*)g_hash_table_lookup(threads, (gpointer)active_thread_id);
- GtkTreeIter frame_iter;
GtkTreeIter thread_iter;
GtkTreePath *path = gtk_tree_row_reference_get_path(reference);
gtk_tree_model_get_iter(model, &thread_iter, path);
gtk_tree_path_free(path);
- gtk_tree_store_insert_before(store, &frame_iter, &thread_iter, 0);
+ g_object_ref (model);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (tree), NULL);
- gtk_tree_store_set (store, &frame_iter, S_FRAME, f, -1);
+ /* prepending is a *lot* faster than appending, so prepend with a reversed data set */
+ for (item = g_list_last (frames); item; item = item->prev)
+ {
+ gtk_tree_store_insert_with_values (store, NULL, &thread_iter, 0,
+ S_FRAME, item->data, -1);
+ }
+
+ gtk_tree_view_set_model (GTK_TREE_VIEW (tree), model);
+ g_object_unref (model);
}
/*
Modified: debugger/src/stree.h
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -31,7 +31,7 @@
GtkWidget* stree_init(move_to_line_cb ml, select_frame_cb sf);
void stree_destroy(void);
-void stree_add(frame *f);
+void stree_add(GList *frames);
void stree_clear(void);
void stree_add_thread(int thread_id);
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).