Kaydet (Commit) 35bde6c5 authored tarafından Jiří Techet's avatar Jiří Techet

Reload a tag in the sidebar only when it differs from the existing tag

gtk_tree_store_set() becomes very slow when the tree gets bigger
because internally it calls gtk_tree_store_get_path() which counts
all the entries in a linked list of elements at the same tree level
to get the tree path.

Avoid the call of this function when not needed.
üst 5d94d159
......@@ -1422,9 +1422,7 @@ static void update_tree_tags(GeanyDocument *doc, GList **tags)
cont = tree_store_remove_row(store, &iter);
else /* tag still exist, update it */
{
const gchar *name;
const gchar *parent_name;
gchar *tooltip;
TMTag *found = found_item->data;
parent_name = get_parent_name(found, doc->file_type->id);
......@@ -1432,16 +1430,22 @@ static void update_tree_tags(GeanyDocument *doc, GList **tags)
if (parent_name && ! g_hash_table_lookup(parents_table, parent_name))
parent_name = NULL;
/* only update fields that (can) have changed (name that holds line
* number, tooltip, and the tag itself) */
name = get_symbol_name(doc, found, parent_name != NULL);
tooltip = get_symbol_tooltip(doc, found);
gtk_tree_store_set(store, &iter,
SYMBOLS_COLUMN_NAME, name,
SYMBOLS_COLUMN_TOOLTIP, tooltip,
SYMBOLS_COLUMN_TAG, found,
-1);
g_free(tooltip);
if (!tm_tags_equal(tag, found))
{
const gchar *name;
gchar *tooltip;
/* only update fields that (can) have changed (name that holds line
* number, tooltip, and the tag itself) */
name = get_symbol_name(doc, found, parent_name != NULL);
tooltip = get_symbol_tooltip(doc, found);
gtk_tree_store_set(store, &iter,
SYMBOLS_COLUMN_NAME, name,
SYMBOLS_COLUMN_TOOLTIP, tooltip,
SYMBOLS_COLUMN_TAG, found,
-1);
g_free(tooltip);
}
update_parents_table(parents_table, found, parent_name, &iter);
......
......@@ -734,6 +734,26 @@ static gint tm_tag_compare(gconstpointer ptr1, gconstpointer ptr2, gpointer user
return returnval;
}
gboolean tm_tags_equal(const TMTag *a, const TMTag *b)
{
if (a == b)
return TRUE;
return (a->line == b->line &&
a->file == b->file /* ptr comparison */ &&
strcmp(FALLBACK(a->name, ""), FALLBACK(b->name, "")) == 0 &&
a->type == b->type &&
a->local == b->local &&
a->pointerOrder == b->pointerOrder &&
a->access == b->access &&
a->impl == b->impl &&
a->lang == b->lang &&
strcmp(FALLBACK(a->scope, ""), FALLBACK(b->scope, "")) == 0 &&
strcmp(FALLBACK(a->arglist, ""), FALLBACK(b->arglist, "")) == 0 &&
strcmp(FALLBACK(a->inheritance, ""), FALLBACK(b->inheritance, "")) == 0 &&
strcmp(FALLBACK(a->var_type, ""), FALLBACK(b->var_type, "")) == 0);
}
/*
Removes NULL tag entries from an array of tags. Called after tm_tags_dedup() since
this function substitutes duplicate entries with NULL
......
......@@ -189,6 +189,7 @@ void tm_tag_unref(TMTag *tag);
TMTag *tm_tag_ref(TMTag *tag);
gboolean tm_tags_equal(const TMTag *a, const TMTag *b);
#ifdef TM_DEBUG /* various debugging functions */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment