[json-glib] object: Use g_list_find_custom()



commit 8b060cd9144990aae6531982bad66050fafcb658
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Fri Apr 8 15:17:19 2011 +0100

    object: Use g_list_find_custom()
    
    Instead of manual iteration, let's use the function GList provides us.

 json-glib/json-object.c |   13 +++----------
 1 files changed, 3 insertions(+), 10 deletions(-)
---
diff --git a/json-glib/json-object.c b/json-glib/json-object.c
index 1a655de..438366b 100644
--- a/json-glib/json-object.c
+++ b/json-glib/json-object.c
@@ -141,16 +141,9 @@ object_set_member_internal (JsonObject  *object,
        * pointer to its name, to avoid keeping invalid pointers
        * once we replace the key in the hash table
        */
-      for (l = object->members_ordered; l != NULL; l =  l->next)
-        {
-          gchar *tmp = l->data;
-
-          if (strcmp (tmp, name) == 0)
-            {
-              l->data = name;
-              break;
-            }
-        }
+      l = g_list_find_custom (object->members_ordered, name, (GCompareFunc) strcmp);
+      if (l != NULL)
+        l->data = name;
     }
 
   g_hash_table_replace (object->members, name, node);



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