From 6a849fe93e84edcc0fc6a3c88fbbf8bf6386a104 Mon Sep 17 00:00:00 2001 From: Alok Barsode Date: Mon, 7 Feb 2011 14:43:06 +0200 Subject: [PATCH] technology: Optimize __connman_technology_remove_interface() Using technology_find() instead of looping through technology_list. --- src/technology.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/technology.c b/src/technology.c index 0a89b1a..a5366dc 100644 --- a/src/technology.c +++ b/src/technology.c @@ -580,7 +580,7 @@ void __connman_technology_add_interface(enum connman_service_type type, void __connman_technology_remove_interface(enum connman_service_type type, int index, const char *name, const char *ident) { - GSList *list; + struct connman_technology *technology; switch (type) { case CONNMAN_SERVICE_TYPE_UNKNOWN: @@ -600,20 +600,15 @@ void __connman_technology_remove_interface(enum connman_service_type type, connman_info("Remove interface %s [ %s ]", name, __connman_service_type2string(type)); - for (list = technology_list; list; list = list->next) { - struct connman_technology *technology = list->data; - - if (technology->type != type) - continue; + technology = technology_find(type); - if (technology->driver == NULL) - continue; + if (technology == NULL || technology->driver == NULL) + return; - if (technology->driver->remove_interface) - technology->driver->remove_interface(technology, index); + if (technology->driver->remove_interface) + technology->driver->remove_interface(technology, index); - technology_put(technology); - } + technology_put(technology); } static void unregister_technology(gpointer data) -- 2.7.4