[folks] Always explicitly iterate through a HashMap's keys, values, or entries.



commit 88e9ea06e4ede971f2f4b623807ac1518f480c42
Author: Travis Reitter <travis reitter collabora co uk>
Date:   Thu Nov 4 17:28:48 2010 -0700

    Always explicitly iterate through a HashMap's keys, values, or entries.

 backends/telepathy/lib/tpf-persona-store.vala |   10 ++++------
 folks/backend-store.vala                      |   20 +++++++-------------
 2 files changed, 11 insertions(+), 19 deletions(-)
---
diff --git a/backends/telepathy/lib/tpf-persona-store.vala b/backends/telepathy/lib/tpf-persona-store.vala
index 5e822c4..18b352d 100644
--- a/backends/telepathy/lib/tpf-persona-store.vala
+++ b/backends/telepathy/lib/tpf-persona-store.vala
@@ -664,7 +664,7 @@ public class Tpf.PersonaStore : Folks.PersonaStore
       if (change_maps.size < 1)
         return;
 
-      foreach (var entry in change_maps)
+      foreach (var entry in change_maps.entries)
         {
           var changes = entry.key;
 
@@ -955,17 +955,15 @@ public class Tpf.PersonaStore : Folks.PersonaStore
       /*
        * remove all persona-keyed entries
        */
-      foreach (var entry in this.channel_group_personas_map)
+      foreach (var channel in this.channel_group_personas_map.keys)
         {
-          var channel = (Channel) entry.key;
           var members = this.channel_group_personas_map[channel];
           if (members != null)
             members.remove (persona);
         }
 
-      foreach (var entry in this.group_outgoing_adds)
+      foreach (var name in this.group_outgoing_adds.keys)
         {
-          var name = (string) entry.key;
           var members = this.group_outgoing_adds[name];
           if (members != null)
             members.remove (persona);
@@ -1375,7 +1373,7 @@ public class Tpf.PersonaStore : Folks.PersonaStore
 
   private void channel_groups_add_new_personas ()
     {
-      foreach (var entry in this.channel_group_incoming_adds)
+      foreach (var entry in this.channel_group_incoming_adds.entries)
         {
           var channel = (Channel) entry.key;
           var members_added = new GLib.List<Persona> ();
diff --git a/folks/backend-store.vala b/folks/backend-store.vala
index 786014c..fd31944 100644
--- a/folks/backend-store.vala
+++ b/folks/backend-store.vala
@@ -77,8 +77,8 @@ public class Folks.BackendStore : Object {
       owned get
         {
           var backends = new GLib.List<Backend> ();
-          foreach (var entry in this._prepared_backends)
-            backends.prepend (entry.value);
+          foreach (var backend in this._prepared_backends.values)
+            backends.prepend (backend);
 
           return backends;
         }
@@ -130,9 +130,8 @@ public class Folks.BackendStore : Object {
   ~BackendStore ()
     {
       /* Finalize all the loaded modules that have finalize functions */
-      foreach (var entry in this.modules)
+      foreach (var module in this.modules.values)
         {
-          unowned Module module = entry.value;
           void* func;
           if (module.symbol ("module_finalize", out func))
             {
@@ -207,17 +206,12 @@ public class Folks.BackendStore : Object {
       /* this will load any new modules found in the backends dir and will
        * prepare and unprepare backends such that they match the state in the
        * backend store key file */
-      foreach (var mod_entry in modules)
-        {
-          var module = (File) mod_entry.value;
-          this.load_module_from_file (module);
-        }
+      foreach (var module in modules.values)
+        this.load_module_from_file (module);
 
       /* this is populated indirectly from load_module_from_file(), above */
       foreach (var backend in this.backend_hash.values)
-        {
-          yield this.backend_load_if_needed (backend);
-        }
+        yield this.backend_load_if_needed (backend);
     }
 
   private async void backend_load_if_needed (Backend backend)
@@ -412,7 +406,7 @@ public class Folks.BackendStore : Object {
           if (file_type == FileType.DIRECTORY)
             {
               var modules = yield this.get_modules_from_dir (file);
-              foreach (var entry in modules)
+              foreach (var entry in modules.entries)
                 modules_final.set (entry.key, entry.value);
             }
           else if (mime == "application/x-sharedlib" && !is_symlink)



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