diff options
author | Niels De Graef <nielsdegraef@gmail.com> | 2022-08-27 09:57:30 +0200 |
---|---|---|
committer | Niels De Graef <nielsdegraef@gmail.com> | 2022-08-27 09:57:30 +0200 |
commit | 4248cc22cdd8c2ad887d3d789a50ea791cb493cb (patch) | |
tree | 38f4ebaa6081be762bb17d421583446fe603068f /src | |
parent | 49b3413874299e0e4c75ede9ebf567f710c1ee16 (diff) | |
download | gnome-contacts-4248cc22cdd8c2ad887d3d789a50ea791cb493cb.tar.gz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/contacts-query-filter.vala | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/contacts-query-filter.vala b/src/contacts-query-filter.vala index b4459c1..81cae41 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; } } |