From: Alan Knowles Date: Sat, 3 Apr 2010 04:24:01 +0000 (+0800) Subject: [GIPARSER] - tidy up searching for var args. X-Git-Url: http://git.roojs.org/?p=gnome.gobject-introspection;a=commitdiff_plain;h=e01555d743ee408c356ca766257af4d29aa6f385 [GIPARSER] - tidy up searching for var args. extract search loop --- diff --git a/girepository/girparser.c b/girepository/girparser.c index 1347945..c45ac78 100644 --- a/girepository/girparser.c +++ b/girepository/girparser.c @@ -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, + ((GIrNode *)callback->data)->name)); + if (callback) + { + list = g_list_delete_link (list, link); + function_done = TRUE; + } + } } }