summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgnacio Casal Quinteiro <icq@gnome.org>2014-12-24 23:00:52 +0100
committerIgnacio Casal Quinteiro <icq@gnome.org>2014-12-24 23:00:52 +0100
commit83f950a1be6bde17330256b1d3e3873c94a95703 (patch)
tree0a48a69a9a010924be17b86b9480cbc46cdec4a5
parentd44e06adb866f2ff41e9035cb3e92219d61bd0bf (diff)
downloadgusb-83f950a1be6bde17330256b1d3e3873c94a95703.tar.gz
context: minor optmization of the rescan
Add the devices after removing the ones that do not exists anymore, this way we avoid checking the new ones.
-rw-r--r--gusb/gusb-context.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/gusb/gusb-context.c b/gusb/gusb-context.c
index 5ced2a1..52536ba 100644
--- a/gusb/gusb-context.c
+++ b/gusb/gusb-context.c
@@ -374,11 +374,6 @@ g_usb_context_rescan (GUsbContext *context)
guint i;
libusb_device **dev_list = NULL;
- /* add any devices not yet added (duplicates will be filtered */
- libusb_get_device_list (priv->ctx, &dev_list);
- for (i = 0; dev_list && dev_list[i]; i++)
- g_usb_context_add_device (context, dev_list[i]);
-
/* copy to a context so we can remove from the array */
for (i = 0; i < priv->devices->len; i++) {
device = g_ptr_array_index (priv->devices, i);
@@ -402,6 +397,11 @@ g_usb_context_rescan (GUsbContext *context)
}
}
+ /* add any devices not yet added (duplicates will be filtered */
+ libusb_get_device_list (priv->ctx, &dev_list);
+ for (i = 0; dev_list && dev_list[i]; i++)
+ g_usb_context_add_device (context, dev_list[i]);
+
g_list_free (existing_devices);
libusb_free_device_list (dev_list, 1);
}