--- a/gplugin/gplugin-manager.c Tue Feb 25 04:25:47 2020 +0000
+++ b/gplugin/gplugin-manager.c Sun Feb 23 00:16:56 2020 -0600
@@ -61,7 +61,7 @@
GHashTable *plugins_filename_view;
+ GHashTable *loaders_by_extension; @@ -257,7 +257,7 @@
* we can prepend our loader. But before we add ours, we remove any
* old copies we might have of ours.
- existing = g_hash_table_lookup(manager->loaders, ext);
+ existing = g_hash_table_lookup(manager->loaders_by_extension, ext); for(ll = existing; ll; ll = ll->next) {
if(G_OBJECT_TYPE(ll->data) == type) {
GPluginLoader *old = GPLUGIN_LOADER(ll->data);
@@ -273,7 +273,8 @@
existing = g_slist_prepend(existing, g_object_ref(G_OBJECT(loader)));
/* Now insert the updated slist back into the hash table */
- g_hash_table_insert(manager->loaders, g_strdup(ext), existing);
+ g_hash_table_insert(manager->loaders_by_extension, g_strdup(ext), /* make a note that we need to refresh */
@@ -303,7 +304,7 @@
ext = (const gchar *)exts->data;
- los = g_hash_table_lookup(manager->loaders, ext);
+ los = g_hash_table_lookup(manager->loaders_by_extension, ext); for(l = los; l; l = l->next) {
GPluginLoader *lo = GPLUGIN_LOADER(l->data);
@@ -318,10 +319,12 @@
los = g_slist_remove(los, lo);
- g_hash_table_insert(manager->loaders, g_strdup(ext), los);
- g_hash_table_remove(manager->loaders, ext);
+ g_hash_table_insert(manager->loaders_by_extension, + g_hash_table_remove(manager->loaders_by_extension, ext); /* kill our ref to the loader */
g_object_unref(G_OBJECT(lo));
@@ -392,9 +395,8 @@
/* grab the list of loaders for this extension */
- for(l = g_hash_table_lookup(manager->loaders, e->extension); l;
+ l = g_hash_table_lookup(manager->loaders_by_extension, e->extension); + for(; l; l = l->next) { @@ -851,10 +853,10 @@
g_clear_pointer(&manager->plugins_filename_view, g_hash_table_destroy);
/* free all the data in the loaders hash table and destroy it */
- g_hash_table_foreach_remove(manager->loaders,
+ g_hash_table_foreach_remove(manager->loaders_by_extension, gplugin_manager_remove_list_value,
- g_clear_pointer(&manager->loaders, g_hash_table_destroy);
+ g_clear_pointer(&manager->loaders_by_extension, g_hash_table_destroy); /* call the base class's destructor */
G_OBJECT_CLASS(gplugin_manager_parent_class)->finalize(obj);
@@ -1011,18 +1013,18 @@
manager->plugins_filename_view =
g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref);
- /* The loaders hash table is keyed on the supported extensions of the
- * loader. Which means that a loader that supports multiple extensions
- * will be in the table multiple times.
+ /* The loaders_by_extension hash table is keyed on the supported extensions + * of the loader. Which means that a loader that supports multiple + * extensions will be in the table multiple times. * We deal with collisions by using a GSList for the value which will hold
* references to instances of the actual loaders.
- * Storing this in this method allows up to quickly figure out which loader
+ * Storing this in this method allows us to quickly figure out which loader * to use by the filename and helps us to avoid iterating the loaders table
+ manager->loaders_by_extension = g_hash_table_new_full(gplugin_manager_str_hash, g_str_equal,