[gnome-builder] clang: limit the number of completion items we generate



commit 2190dce80bcd1139d5d9e269bf3f215331e3bed1
Author: Christian Hergert <christian hergert me>
Date:   Thu Apr 9 16:16:13 2015 -0700

    clang: limit the number of completion items we generate
    
    These can get out of hand (many thousands), so let's restrict it a bit
    for now. This is not the smartest about which items we should display,
    and that should be added at some point.
    
    In particular, we should look at the wording to promote high value targets.

 libide/clang/ide-clang-completion-provider.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/libide/clang/ide-clang-completion-provider.c b/libide/clang/ide-clang-completion-provider.c
index fe534e3..8d8e6e6 100644
--- a/libide/clang/ide-clang-completion-provider.c
+++ b/libide/clang/ide-clang-completion-provider.c
@@ -33,6 +33,8 @@
 #include "ide-source-snippet.h"
 #include "ide-source-view.h"
 
+#define MAX_COMPLETION_ITEMS 200
+
 struct _IdeClangCompletionProviderClass
 {
   GObjectClass parent_class;
@@ -153,7 +155,18 @@ filter_list (GPtrArray   *ar,
 
       item = g_ptr_array_index (ar, i);
       if (matches (item, word))
-        g_ptr_array_add (matched, item);
+        {
+          g_ptr_array_add (matched, item);
+
+          /*
+           * FIXME:
+           *
+           * We should be a bit more intelligent about which items we accept.
+           * The results don't come to us in "most important" order.
+           */
+          if (G_UNLIKELY (ar->len == MAX_COMPLETION_ITEMS))
+            break;
+        }
     }
 
   for (i = 0; i < matched->len; i++)


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