From eef0e079ab8860d7c4f754b0ca98c2d66e449e07 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Wed, 3 Nov 2021 10:05:18 +0000 Subject: [PATCH] Speed up daemon startup by ~2% We populate the plugin name hash table, but we forgot to use it. --- src/fu-plugin-list.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/fu-plugin-list.c b/src/fu-plugin-list.c index bd13d38d7..ee7d0d06a 100644 --- a/src/fu-plugin-list.c +++ b/src/fu-plugin-list.c @@ -115,16 +115,18 @@ fu_plugin_list_add(FuPluginList *self, FuPlugin *plugin) FuPlugin * fu_plugin_list_find_by_name(FuPluginList *self, const gchar *name, GError **error) { + FuPlugin *plugin; + g_return_val_if_fail(FU_IS_PLUGIN_LIST(self), NULL); g_return_val_if_fail(name != NULL, NULL); g_return_val_if_fail(error == NULL || *error == NULL, NULL); - for (guint i = 0; i < self->plugins->len; i++) { - FuPlugin *plugin = g_ptr_array_index(self->plugins, i); - if (g_strcmp0(fu_plugin_get_name(plugin), name) == 0) - return plugin; + + plugin = g_hash_table_lookup(self->plugins_hash, name); + if (plugin == NULL) { + g_set_error(error, FWUPD_ERROR, FWUPD_ERROR_NOT_FOUND, "no plugin %s found", name); + return NULL; } - g_set_error(error, FWUPD_ERROR, FWUPD_ERROR_NOT_FOUND, "no plugin %s found", name); - return NULL; + return plugin; } static gint