gstregistry: Directly get list of plugin features
authorEdward Hervey <edward@centricular.com>
Tue, 5 May 2020 08:47:07 +0000 (10:47 +0200)
committerEdward Hervey <bilboed@bilboed.com>
Tue, 5 May 2020 08:50:05 +0000 (10:50 +0200)
Previously this was:
* iterating and referencing all plugin features in a GList
* *then* filtering out the ones we want
* Was doing that filtering by name (i.e. `strcmp`) instead of direct pointer
comparision

Instead, just create a private direct function to get the list of plugin
features

Uses 4 times less instructions ...

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/462>

gst/gst_private.h
gst/gstregistry.c
gst/gstregistrychunks.c

index 3cd2d3d..8eb28cf 100644 (file)
@@ -92,6 +92,10 @@ struct _GstPluginPrivate {
   GstStructure *cache_data;
 };
 
+/* Private function for getting plugin features directly */
+GList *
+_priv_plugin_get_features(GstRegistry *registry, GstPlugin *plugin);
+
 /* Needed by GstMeta (to access meta seq) and GstBuffer (create/free/iterate) */
 typedef struct _GstMetaItem GstMetaItem;
 struct _GstMetaItem {
index 4bc5e8f..7ed85d7 100644 (file)
@@ -1429,6 +1429,24 @@ gst_registry_get_feature_list_by_plugin (GstRegistry * registry,
       _gst_plugin_feature_filter_plugin_name, FALSE, (gpointer) name);
 }
 
+/* Private function for getting plugin features directly */
+GList *
+_priv_plugin_get_features (GstRegistry * registry, GstPlugin * plugin)
+{
+  GList *res = NULL;
+  GList *walk;
+
+  GST_OBJECT_LOCK (registry);
+  for (walk = registry->priv->features; walk; walk = walk->next) {
+    GstPluginFeature *feat = (GstPluginFeature *) walk->data;
+    if (feat->plugin == plugin)
+      res = g_list_prepend (res, gst_object_ref (feat));
+  }
+  GST_OBJECT_UNLOCK (registry);
+
+  return res;
+}
+
 /* Unref and delete the default registry */
 void
 _priv_gst_registry_cleanup (void)
index e8fb3ac..15015d8 100644 (file)
@@ -460,8 +460,7 @@ _priv_gst_registry_chunks_save_plugin (GList ** list, GstRegistry * registry,
   }
 
   /* pack plugin features */
-  plugin_features =
-      gst_registry_get_feature_list_by_plugin (registry, plugin->desc.name);
+  plugin_features = _priv_plugin_get_features (registry, plugin);
   for (walk = plugin_features; walk; walk = g_list_next (walk), pe->nfeatures++) {
     GstPluginFeature *feature = GST_PLUGIN_FEATURE (walk->data);