[gnome-contacts] query-filter: Optimize for empty SimpleQuery



commit 4248cc22cdd8c2ad887d3d789a50ea791cb493cb
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Sat Aug 27 09:57:30 2022 +0200

    query-filter: Optimize for empty SimpleQuery
    
    When starting the application (or when the user removes the input from
    the search entry), the `QueryFilter` object we use to filter our
    contacts will match any item. GTK allows us to specify this in the
    `get_strictness()` method by returning `Gtk.FilterMatch.ALL`, which
    is a performance improvement, as it doesn't have to iterate over all the
    items in the list anymore.

 src/contacts-query-filter.vala | 4 ++++
 1 file changed, 4 insertions(+)
---
diff --git a/src/contacts-query-filter.vala b/src/contacts-query-filter.vala
index b4459c1a..81cae41d 100644
--- a/src/contacts-query-filter.vala
+++ b/src/contacts-query-filter.vala
@@ -99,6 +99,10 @@ public class Contacts.QueryFilter : Gtk.Filter {
   }
 
   public override Gtk.FilterMatch get_strictness () {
+    if (this.query is SimpleQuery &&
+        ((SimpleQuery) query).query_string == "")
+      return Gtk.FilterMatch.ALL;
+
     return Gtk.FilterMatch.SOME;
   }
 }


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