[gnome-builder/wip/chergert/layout] extensions: use hashtable to locate extension



commit 9fa0f038e02f88f0ac82762e3033a72dea3a0913
Author: Christian Hergert <chergert redhat com>
Date:   Fri Jul 14 20:13:10 2017 -0700

    extensions: use hashtable to locate extension
    
    This can be done with a hashtable lookup which is already
    indexed by the plugin info.

 libide/plugins/ide-extension-set-adapter.c |   32 +---------------------------
 1 files changed, 1 insertions(+), 31 deletions(-)
---
diff --git a/libide/plugins/ide-extension-set-adapter.c b/libide/plugins/ide-extension-set-adapter.c
index f1cc94a..247a8b0 100644
--- a/libide/plugins/ide-extension-set-adapter.c
+++ b/libide/plugins/ide-extension-set-adapter.c
@@ -551,27 +551,6 @@ ide_extension_set_adapter_new (IdeContext  *context,
                        NULL);
 }
 
-static void
-locate_extension_by_plugin_info (IdeExtensionSetAdapter *self,
-                                 PeasPluginInfo         *plugin_info,
-                                 PeasExtension          *exten,
-                                 gpointer                user_data)
-{
-  struct {
-    PeasPluginInfo *plugin_info;
-    PeasExtension  *exten;
-  } *lookup = user_data;
-
-  g_assert (IDE_IS_EXTENSION_SET_ADAPTER (self));
-  g_assert (plugin_info != NULL);
-  g_assert (exten != NULL);
-  g_assert (lookup != NULL);
-  g_assert (lookup->plugin_info != NULL);
-
-  if (lookup->plugin_info == plugin_info)
-    lookup->exten = exten;
-}
-
 /**
  * ide_extension_set_adapter_get_extension:
  * @self: a #IdeExtensionSetAdapter
@@ -585,17 +564,8 @@ PeasExtension *
 ide_extension_set_adapter_get_extension (IdeExtensionSetAdapter *self,
                                          PeasPluginInfo         *plugin_info)
 {
-  struct {
-    PeasPluginInfo *plugin_info;
-    PeasExtension  *exten;
-  } lookup = { plugin_info, NULL };
-
   g_return_val_if_fail (IDE_IS_EXTENSION_SET_ADAPTER (self), NULL);
   g_return_val_if_fail (plugin_info != NULL, NULL);
 
-  ide_extension_set_adapter_foreach (self,
-                                     locate_extension_by_plugin_info,
-                                     &lookup);
-
-  return lookup.exten;
+  return g_hash_table_lookup (self->extensions, plugin_info);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]