[gtk] [GtkSearchEngineQuartz] Limit the returned hits.



commit 52b9e4703b98da8b4f808b0039f1d36d187c5837
Author: John Ralls <jralls ceridwen us>
Date:   Sun Jan 6 16:19:49 2019 -0800

    [GtkSearchEngineQuartz] Limit the returned hits.
    
    When the result set is larger than the limit.

 gtk/gtksearchenginequartz.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtksearchenginequartz.c b/gtk/gtksearchenginequartz.c
index 972983aa3d..95558a07f2 100644
--- a/gtk/gtksearchenginequartz.c
+++ b/gtk/gtksearchenginequartz.c
@@ -73,9 +73,14 @@ G_DEFINE_TYPE_WITH_PRIVATE (GtkSearchEngineQuartz, _gtk_search_engine_quartz, GT
 {
   int i;
   GList *hits = NULL;
+  /* The max was originally set to 1000 to mimic something called "the
+   * boogie backend".
+   */
+  const unsigned int max_hits = 1000;
+  const unsigned int max_iter = submitted_hits + [ns_query resultCount];
 
   /* Here we submit hits "submitted_hits" to "resultCount" */
-  for (i = submitted_hits; i < [ns_query resultCount]; i++)
+  for (i = submitted_hits; i < max_iter && i < max_hits; ++i)
     {
       id result = [ns_query resultAtIndex:i];
       const char *result_path;
@@ -95,15 +100,10 @@ G_DEFINE_TYPE_WITH_PRIVATE (GtkSearchEngineQuartz, _gtk_search_engine_quartz, GT
   _gtk_search_engine_hits_added (engine, hits);
   g_list_free_full (hits, (GDestroyNotify) _gtk_search_hit_free);
 
-  submitted_hits += [ns_query resultCount];
-
-  /* The beagle backend stops at 1000 hits, so guess we do so too here.
-   * It works pretty snappy on my MacBook, if we get rid of this limit
-   * we are almost definitely going to need some code to submit hits
-   * in batches.
-   */
-  if (submitted_hits > 25)
+  if (max_iter >= max_hits)
     [ns_query stopQuery];
+
+  submitted_hits = max_iter;
 }
 
 - (void) queryUpdate:(id)sender


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