[gnome-builder] fuzzy: if no max item is set, don't sort/filter results



commit a9bcb48bf5a5059e7425abf80686f6c60599dec4
Author: Christian Hergert <christian hergert me>
Date:   Fri Jun 12 20:40:50 2015 -0700

    fuzzy: if no max item is set, don't sort/filter results
    
    This allows avoiding a sort when we will go through the search reducer
    in a later phase.

 contrib/search/fuzzy.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/contrib/search/fuzzy.c b/contrib/search/fuzzy.c
index c805668..6401556 100644
--- a/contrib/search/fuzzy.c
+++ b/contrib/search/fuzzy.c
@@ -477,15 +477,18 @@ fuzzy_match (Fuzzy       *fuzzy,
       g_array_append_val (matches, match);
     }
 
-  g_array_sort (matches, fuzzy_match_compare);
-
   /*
    * TODO: We could be more clever here when inserting into the array
    *       only if it is a lower score than the end or < max items.
    */
 
-  if (max_matches && (matches->len > max_matches))
-    g_array_set_size (matches, max_matches);
+  if (max_matches != 0)
+    {
+      g_array_sort (matches, fuzzy_match_compare);
+
+      if (max_matches && (matches->len > max_matches))
+        g_array_set_size (matches, max_matches);
+    }
 
 cleanup:
   g_free (downcase);


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