[gnome-contacts] ContactsContact: return early in calc_is_main()



commit 0f0dffd4127a0d064b461faf3ace5619e5cb1cf2
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Fri Dec 29 03:04:49 2017 +0100

    ContactsContact: return early in calc_is_main()
    
    Don't do work if it's not necessary.

 src/contacts-contact.vala |   15 +++++----------
 1 files changed, 5 insertions(+), 10 deletions(-)
---
diff --git a/src/contacts-contact.vala b/src/contacts-contact.vala
index e921b47..aafc14c 100644
--- a/src/contacts-contact.vala
+++ b/src/contacts-contact.vala
@@ -140,20 +140,15 @@ public class Contacts.Contact : GLib.Object  {
       return false;
 
     // Mark google contacts not in "My Contacts" as non-main
-    if (persona_is_google_other (persona)) {
-      return false;
-    }
-
-    return true;
+    return !persona_is_google_other (persona);
   }
 
   private bool calc_is_main () {
-    var res = false;
-    foreach (var p in individual.personas) {
+    foreach (var p in this.individual.personas)
       if (persona_is_main (p))
-       res = true;
-    }
-    return res;
+        return true;
+
+    return false;
   }
 
   public Contact (Store store, Individual i) {


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