[gnome-builder] ctags: use hashtable to prevent double entries



commit 44b5f8e46d6dcca6437afc9a14982b7e06ce9aef
Author: chandu <anoopchandu18 gmail com>
Date:   Sat Feb 20 20:06:00 2016 +0000

    ctags: use hashtable to prevent double entries
    
    https://bugzilla.gnome.org/show_bug.cgi?id=761446

 plugins/ctags/ide-ctags-completion-provider.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/plugins/ctags/ide-ctags-completion-provider.c b/plugins/ctags/ide-ctags-completion-provider.c
index fc6e1e9..98230c0 100644
--- a/plugins/ctags/ide-ctags-completion-provider.c
+++ b/plugins/ctags/ide-ctags-completion-provider.c
@@ -174,6 +174,7 @@ ide_ctags_completion_provider_populate (GtkSourceCompletionProvider *provider,
   gint word_len;
   guint i;
   guint j;
+  g_autoptr(GHashTable) completions = NULL;
 
   IDE_ENTRY;
 
@@ -203,12 +204,13 @@ ide_ctags_completion_provider_populate (GtkSourceCompletionProvider *provider,
 
   self->results = ide_completion_results_new (self->current_word);
 
+  completions = g_hash_table_new (g_str_hash, g_str_equal);
+
   for (i = 0; i < self->indexes->len; i++)
     {
       g_autofree gchar *copy = g_strdup (self->current_word);
       IdeCtagsIndex *index = g_ptr_array_index (self->indexes, i);
       const IdeCtagsIndexEntry *entries = NULL;
-      const gchar *last_name = NULL;
       guint tmp_len = word_len;
       gsize n_entries = 0;
       gchar gdata_key[64];
@@ -235,10 +237,10 @@ ide_ctags_completion_provider_populate (GtkSourceCompletionProvider *provider,
           const IdeCtagsIndexEntry *entry = &entries [j];
           IdeCtagsCompletionItem *item;
 
-          if (ide_str_equal0 (entry->name, last_name))
+          if (g_hash_table_contains (completions, entry->name))
             continue;
 
-          last_name = entry->name;
+          g_hash_table_add (completions, entry->name);
 
           if (!ide_ctags_is_allowed (entry, allowed))
             continue;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]