[GIPARSER] - tidy up of var args
authorAlan Knowles <alan@akbkhome.com>
Sat, 3 Apr 2010 06:57:35 +0000 (14:57 +0800)
committerAlan Knowles <alan@akbkhome.com>
Sat, 3 Apr 2010 06:57:35 +0000 (14:57 +0800)
Simplify searching for node (so it can be used elsewhere later)

girepository/girparser.c

index bee89ee..1e48bdb 100644 (file)
@@ -3195,6 +3195,28 @@ post_filter_toplevel_varargs_functions (GList *list,
   return list;
 }
 
+
+/* 
+  quick look up of node in the list..
+  return null, or a pointer to the list item..
+ */
+static GList *
+node_find_in_list(GList *list, const char *name)
+{
+  GList *link;
+  for (link = list;
+       link;
+       link = link->next)
+    {
+      if (!strcmp (name, ((GIrNode *)link->data)->name))
+       return link;
+    }
+  return NULL;
+}
+
+
+
 static GList *
 post_filter_varargs_functions (GList *list, GList ** varargs_callbacks_out)
 {
@@ -3229,19 +3251,16 @@ post_filter_varargs_functions (GList *list, GList ** varargs_callbacks_out)
 
              if (node->type->is_interface)
                {
-                 GList *callback;
-                 for (callback = varargs_callbacks;
-                      callback;
-                      callback = callback->next)
-                   {
-                     if (!strcmp (node->type->interface,
-                                  ((GIrNode *)callback->data)->name))
-                       {
-                         list = g_list_delete_link (list, link);
-                         function_done = TRUE;
-                         break;
-                       }
-                   }
+       
+                 GList *callback = node_find_in_list(
+                                       varargs_callbacks, 
+                                       node->type->interface);
+                 if (callback)
+                    {
+                      list = g_list_delete_link (list, link);
+                      function_done = TRUE;
+                    }
+                    
                }
            }
        }