[gnome-contacts] ContactList: don't call Settings on each sort.
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] ContactList: don't call Settings on each sort.
- Date: Sun, 8 Apr 2018 19:55:42 +0000 (UTC)
commit 1a253e67052712c47c8aedba59be47d18ffad067
Author: Niels De Graef <nielsdegraef gmail com>
Date: Sun Apr 8 18:57:53 2018 +0200
ContactList: don't call Settings on each sort.
This was being called *a lot* without the value being cached. This
should improve that.
src/contacts-contact-list.vala | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/src/contacts-contact-list.vala b/src/contacts-contact-list.vala
index 08fa8a3..5a0dd0e 100644
--- a/src/contacts-contact-list.vala
+++ b/src/contacts-contact-list.vala
@@ -103,7 +103,7 @@ public class Contacts.ContactList : ListBox {
private Store store;
- private Settings settings;
+ private bool sort_on_surname = false; // keep in sync with the setting
public UiState state { get; set; }
@@ -116,8 +116,10 @@ public class Contacts.ContactList : ListBox {
this.notify["state"].connect (on_ui_state_changed);
- this.settings = settings;
- this.settings.changed["sort-on-surname"].connect(invalidate_sort);
+ settings.changed["sort-on-surname"].connect(() => {
+ this.sort_on_surname = settings.sort_on_surname;
+ invalidate_sort();
+ });
this.store.added.connect (contact_added_cb);
this.store.removed.connect (contact_removed_cb);
@@ -153,8 +155,8 @@ public class Contacts.ContactList : ListBox {
return a.is_favourite? -1 : 1;
// Both are (non-)favourites: sort by either first name or surname (user preference)
- unowned string? a_name = this.settings.sort_on_surname? try_get_surname(a) : a.display_name;
- unowned string? b_name = this.settings.sort_on_surname? try_get_surname(b) : b.display_name;
+ unowned string? a_name = this.sort_on_surname? try_get_surname(a) : a.display_name;
+ unowned string? b_name = this.sort_on_surname? try_get_surname(b) : b.display_name;
return a_name.collate (b_name);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]