[geany/geany] 35bde6: Reload a tag in the sidebar only when it differs from the existing tag

Jiří Techet git-noreply at xxxxx
Sun May 3 17:36:26 UTC 2015


Branch:      refs/heads/master
Author:      Jiří Techet <techet at gmail.com>
Committer:   Jiří Techet <techet at gmail.com>
Date:        Sun, 03 May 2015 17:36:26 UTC
Commit:      35bde6c5ad0d008f807b88f8430517c282d2bc00
             https://github.com/geany/geany/commit/35bde6c5ad0d008f807b88f8430517c282d2bc00

Log Message:
-----------
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.


Modified Paths:
--------------
    src/symbols.c
    tagmanager/src/tm_tag.c
    tagmanager/src/tm_tag.h

Modified: src/symbols.c
28 lines changed, 16 insertions(+), 12 deletions(-)
===================================================================
@@ -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);
 


Modified: tagmanager/src/tm_tag.c
20 lines changed, 20 insertions(+), 0 deletions(-)
===================================================================
@@ -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


Modified: tagmanager/src/tm_tag.h
1 lines changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -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 */
 



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list