[folks] EdsTest.Backend: add contacts as a batch, not one at a time



commit c0935ea5bcb4b1b3db15f2f36a24d990a16dc2f4
Author: Simon McVittie <simon mcvittie collabora co uk>
Date:   Fri Mar 15 18:22:38 2013 +0000

    EdsTest.Backend: add contacts as a batch, not one at a time
    
    This should make it much quicker to add contacts in bulk.
    
    Bug https://bugzilla.gnome.org/show_bug.cgi?id=696104
    Signed-off-by: Simon McVittie <simon mcvittie collabora co uk>
    Reviewed-by: Philip Withnall <philip tecnocode co uk>

 tests/lib/eds/backend.vala |   31 +++++++++++++++++++------------
 1 files changed, 19 insertions(+), 12 deletions(-)
---
diff --git a/tests/lib/eds/backend.vala b/tests/lib/eds/backend.vala
index 17edd5b..fc4e432 100644
--- a/tests/lib/eds/backend.vala
+++ b/tests/lib/eds/backend.vala
@@ -193,25 +193,32 @@ public class EdsTest.Backend
 
   public async void commit_contacts_to_addressbook ()
     {
+      GLib.SList<E.Contact> contacts = null;
+
       this._contacts.reverse ();
+
       foreach (var c in this._contacts)
         {
           E.Contact contact = new E.Contact ();
 
           this._set_contact_fields (contact, c);
 
-          try
-            {
-              string added_uid;
-              yield this._addressbook.add_contact (contact,
-                  null, out added_uid);
-              this._e_contacts += (owned) added_uid;
-            }
-          catch (GLib.Error e)
-            {
-              GLib.warning ("Couldn't add contact: %s\n",
-                  e.message);
-            }
+          contacts.prepend (contact);
+        }
+
+      try
+        {
+          GLib.SList<string> uids;
+
+          yield this._addressbook.add_contacts (contacts, null, out uids);
+
+          foreach (unowned string uid in uids)
+            this._e_contacts += uid;
+        }
+      catch (GLib.Error e)
+        {
+          GLib.warning ("Couldn't add contacts: %s\n",
+              e.message);
         }
     }
 


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