[folks/648811-dummy-backend-rebase1] dummy: Tidy up code in PersonaStore.remove_persona()



commit f51542acb0876e102caa5994e5ec967aa5544583
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Mon Nov 11 13:47:53 2013 +0000

    dummy: Tidy up code in PersonaStore.remove_persona()
    
    It was doing twice as many HashMap operations as strictly necessary,
    and was using a potentially incorrect pointer in the signal emission
    (i.e. using the Persona pointer provided by the caller, rather than
    the one which was just removed from the personas map).

 backends/dummy/lib/dummy-persona-store.vala |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)
---
diff --git a/backends/dummy/lib/dummy-persona-store.vala b/backends/dummy/lib/dummy-persona-store.vala
index 2d97cbf..90e6a35 100644
--- a/backends/dummy/lib/dummy-persona-store.vala
+++ b/backends/dummy/lib/dummy-persona-store.vala
@@ -605,11 +605,9 @@ public class FolksDummy.PersonaStore : Folks.PersonaStore
           yield this._implement_mock_delay (delay);
         }
 
-      Persona? _persona = this._personas.get (persona.iid);
-      if (_persona != null)
+      Persona? _persona = null;
+      if (this._personas.unset (persona.iid, out _persona) == true)
         {
-          this._personas.unset (persona.iid);
-
           /* Handle the case where a contact is removed while persona changes
            * are frozen. */
           this._pending_persona_registrations.remove ((!) _persona);
@@ -617,7 +615,7 @@ public class FolksDummy.PersonaStore : Folks.PersonaStore
 
           /* Notify of the removal. */
           var removed_personas = new HashSet<Folks.Persona> ();
-          removed_personas.add ((!) persona);
+          removed_personas.add ((!) _persona);
           this._emit_personas_changed (null, removed_personas);
         }
     }


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