From 2aee9bc22451ea00e1e40c531c886d69654003c7 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sun, 12 Jul 2009 00:25:55 -0700 Subject: [PATCH] Use the interface index for fast device comparison --- src/udev.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/udev.c b/src/udev.c index 276f64e..f03f952 100644 --- a/src/udev.c +++ b/src/udev.c @@ -57,19 +57,19 @@ static GSList *device_list = NULL; static struct connman_device *find_device(const char *interface) { GSList *list; + int index; if (interface == NULL) return NULL; + index = connman_inet_ifindex(interface); + if (index < 0) + return NULL; + for (list = device_list; list; list = list->next) { struct connman_device *device = list->data; - const char *device_interface; - - device_interface = connman_device_get_interface(device); - if (device_interface == NULL) - continue; - if (g_str_equal(device_interface, interface) == TRUE) + if (connman_device_get_index(device) == index) return device; } -- 2.7.4