[Github-comments] [geany] Store "equal" tags into binary trees instead of lists in Symbol tree (#797)
Colomban Wendling
notifications at xxxxx
Sat Jan 2 18:08:21 UTC 2016
> }
> - *list = g_list_prepend(*list, g_slice_dup(GtkTreeIter, iter));
> +
> + gtk_tree_model_get(GTK_TREE_MODEL(store), iter, SYMBOLS_COLUMN_TAG, &tag, -1);
something like this
```diff
diff --git a/src/symbols.c b/src/symbols.c
index fed7b2f..cee0d1b 100644
--- a/src/symbols.c
+++ b/src/symbols.c
@@ -1315,24 +1315,20 @@ static void parents_table_tree_value_free(gpointer data)
/* adds a new element in the parent table if it's key is known. */
-static void update_parents_table(GHashTable *table, gchar *name, const gchar *parent_name,
- GtkTreeIter *iter, GtkTreeStore *store)
+static void update_parents_table(GHashTable *table, const TMTag *tag, const gchar *parent_name,
+ const GtkTreeIter *iter)
{
GTree *tree;
- if (g_hash_table_lookup_extended(table, name, NULL, (gpointer *) &tree) &&
- ! utils_str_equal(parent_name, name) /* prevent Foo::Foo from making parent = child */)
+ if (g_hash_table_lookup_extended(table, tag->name, NULL, (gpointer *) &tree) &&
+ ! utils_str_equal(parent_name, tag->name) /* prevent Foo::Foo from making parent = child */)
{
- TMTag *tag;
-
if (!tree)
{
tree = g_tree_new_full(tree_cmp, NULL, NULL, parents_table_tree_value_free);
- g_hash_table_insert(table, name, tree);
+ g_hash_table_insert(table, tag->name, tree);
}
- gtk_tree_model_get(GTK_TREE_MODEL(store), iter, SYMBOLS_COLUMN_TAG, &tag, -1);
g_tree_insert(tree, GINT_TO_POINTER(tag->line), g_slice_dup(GtkTreeIter, iter));
- tm_tag_unref(tag);
}
}
@@ -1545,7 +1541,7 @@ static void update_tree_tags(GeanyDocument *doc, GList **tags)
g_free(tooltip);
}
- update_parents_table(parents_table, found->name, parent_name, &iter, store);
+ update_parents_table(parents_table, found, parent_name, &iter);
/* remove the updated tag from the table and list */
tags_table_remove(tags_table, found);
@@ -1604,7 +1600,7 @@ static void update_tree_tags(GeanyDocument *doc, GList **tags)
if (G_LIKELY(icon))
g_object_unref(icon);
- update_parents_table(parents_table, tag->name, parent_name, &iter, store);
+ update_parents_table(parents_table, tag, parent_name, &iter);
if (expand)
tree_view_expand_to_iter(GTK_TREE_VIEW(doc->priv->tag_tree), &iter);
```
---
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/797/files#r48686289
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20160102/37fb4ff9/attachment.html>
More information about the Github-comments
mailing list