summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim.muller@collabora.co.uk>2011-11-12 14:55:07 +0000
committerTim-Philipp Müller <tim.muller@collabora.co.uk>2011-11-12 14:57:48 +0000
commit4d6795dcd15f957ba9faf98056d9442be3a40eee (patch)
tree22368db640422c06e6de0985783b85f4a9e58c69
parent147fa8b1f7221cb3917b545143abf84cce9d7f88 (diff)
downloadgstreamer-4d6795dcd15f957ba9faf98056d9442be3a40eee.tar.gz
gst, controller: replace g_list_prepend + reverse with GQueue
-rw-r--r--gst/gstelementfactory.c6
-rw-r--r--gst/gstparse.c16
-rw-r--r--gst/gstplugin.c36
-rw-r--r--libs/gst/controller/gstinterpolationcontrolsource.c8
4 files changed, 27 insertions, 39 deletions
diff --git a/gst/gstelementfactory.c b/gst/gstelementfactory.c
index 0eca4576d7..a74183c569 100644
--- a/gst/gstelementfactory.c
+++ b/gst/gstelementfactory.c
@@ -888,7 +888,7 @@ GList *
gst_element_factory_list_filter (GList * list,
const GstCaps * caps, GstPadDirection direction, gboolean subsetonly)
{
- GList *result = NULL;
+ GQueue results = G_QUEUE_INIT;
GST_DEBUG ("finding factories");
@@ -922,7 +922,7 @@ gst_element_factory_list_filter (GList * list,
if ((subsetonly && gst_caps_is_subset (caps, tmpl_caps)) ||
(!subsetonly && gst_caps_can_intersect (caps, tmpl_caps))) {
/* non empty intersection, we can use this element */
- result = g_list_prepend (result, gst_object_ref (factory));
+ g_queue_push_tail (&results, gst_object_ref (factory));
gst_caps_unref (tmpl_caps);
break;
}
@@ -930,5 +930,5 @@ gst_element_factory_list_filter (GList * list,
}
}
}
- return g_list_reverse (result);
+ return results.head;
}
diff --git a/gst/gstparse.c b/gst/gstparse.c
index 910fc8f702..a2d3d3deaf 100644
--- a/gst/gstparse.c
+++ b/gst/gstparse.c
@@ -44,12 +44,6 @@
#include "parse/types.h"
#endif
-static void
-_prepend_missing_element (gchar * element, GList ** list)
-{
- *list = g_list_prepend (*list, g_strdup (element));
-}
-
static GstParseContext *
gst_parse_context_copy (const GstParseContext * context)
{
@@ -58,9 +52,13 @@ gst_parse_context_copy (const GstParseContext * context)
ret = gst_parse_context_new ();
if (context) {
- g_list_foreach (context->missing_elements, (GFunc) _prepend_missing_element,
- &ret->missing_elements);
- ret->missing_elements = g_list_reverse (ret->missing_elements);
+ GQueue missing_copy = G_QUEUE_INIT;
+ GList *l;
+
+ for (l = context->missing_elements; l != NULL; l = l->next)
+ g_queue_push_tail (&missing_copy, g_strdup ((const gchar *) l->data));
+
+ ret->missing_elements = missing_copy.head;
}
#endif
return ret;
diff --git a/gst/gstplugin.c b/gst/gstplugin.c
index 4db7612d13..02e5cc959e 100644
--- a/gst/gstplugin.c
+++ b/gst/gstplugin.c
@@ -1451,12 +1451,11 @@ _priv_plugin_deps_env_vars_changed (GstPlugin * plugin)
return FALSE;
}
-static GList *
+static void
gst_plugin_ext_dep_extract_env_vars_paths (GstPlugin * plugin,
- GstPluginDep * dep)
+ GstPluginDep * dep, GQueue * paths)
{
gchar **evars;
- GList *paths = NULL;
for (evars = dep->env_vars; evars != NULL && *evars != NULL; ++evars) {
const gchar *e;
@@ -1503,9 +1502,9 @@ gst_plugin_ext_dep_extract_env_vars_paths (GstPlugin * plugin,
full_path = g_strdup (arr[i]);
}
- if (!g_list_find_custom (paths, full_path, (GCompareFunc) strcmp)) {
+ if (!g_queue_find_custom (paths, full_path, (GCompareFunc) strcmp)) {
GST_LOG_OBJECT (plugin, "path: '%s'", full_path);
- paths = g_list_prepend (paths, full_path);
+ g_queue_push_tail (paths, full_path);
full_path = NULL;
} else {
GST_LOG_OBJECT (plugin, "path: '%s' (duplicate,ignoring)", full_path);
@@ -1519,10 +1518,7 @@ gst_plugin_ext_dep_extract_env_vars_paths (GstPlugin * plugin,
g_strfreev (components);
}
- GST_LOG_OBJECT (plugin, "Extracted %d paths from environment",
- g_list_length (paths));
-
- return paths;
+ GST_LOG_OBJECT (plugin, "Extracted %d paths from environment", paths->length);
}
static guint
@@ -1668,43 +1664,37 @@ static guint
gst_plugin_ext_dep_get_stat_hash (GstPlugin * plugin, GstPluginDep * dep)
{
gboolean paths_are_default_only;
- GList *scan_paths;
+ GQueue scan_paths = G_QUEUE_INIT;
guint scan_hash = 0;
+ gchar *path;
GST_LOG_OBJECT (plugin, "start");
paths_are_default_only =
dep->flags & GST_PLUGIN_DEPENDENCY_FLAG_PATHS_ARE_DEFAULT_ONLY;
- scan_paths = gst_plugin_ext_dep_extract_env_vars_paths (plugin, dep);
+ gst_plugin_ext_dep_extract_env_vars_paths (plugin, dep, &scan_paths);
- if (scan_paths == NULL || !paths_are_default_only) {
+ if (g_queue_is_empty (&scan_paths) || !paths_are_default_only) {
gchar **paths;
for (paths = dep->paths; paths != NULL && *paths != NULL; ++paths) {
const gchar *path = *paths;
- if (!g_list_find_custom (scan_paths, path, (GCompareFunc) strcmp)) {
+ if (!g_queue_find_custom (&scan_paths, path, (GCompareFunc) strcmp)) {
GST_LOG_OBJECT (plugin, "path: '%s'", path);
- scan_paths = g_list_prepend (scan_paths, g_strdup (path));
+ g_queue_push_tail (&scan_paths, g_strdup (path));
} else {
GST_LOG_OBJECT (plugin, "path: '%s' (duplicate, ignoring)", path);
}
}
}
- /* not that the order really matters, but it makes debugging easier */
- scan_paths = g_list_reverse (scan_paths);
-
- while (scan_paths != NULL) {
- const gchar *path = scan_paths->data;
-
+ while ((path = g_queue_pop_head (&scan_paths))) {
scan_hash += gst_plugin_ext_dep_scan_path_with_filenames (plugin, path,
(const gchar **) dep->names, dep->flags);
scan_hash = scan_hash << 1;
-
- g_free (scan_paths->data);
- scan_paths = g_list_delete_link (scan_paths, scan_paths);
+ g_free (path);
}
GST_LOG_OBJECT (plugin, "done, scan_hash: %08x", scan_hash);
diff --git a/libs/gst/controller/gstinterpolationcontrolsource.c b/libs/gst/controller/gstinterpolationcontrolsource.c
index 8f7d1d86f6..f320d7d0fc 100644
--- a/libs/gst/controller/gstinterpolationcontrolsource.c
+++ b/libs/gst/controller/gstinterpolationcontrolsource.c
@@ -604,9 +604,9 @@ gst_interpolation_control_source_unset_all (GstInterpolationControlSource *
}
static void
-_append_control_point (GstControlPoint * cp, GList ** l)
+_append_control_point (GstControlPoint * cp, GQueue * res)
{
- *l = g_list_prepend (*l, cp);
+ g_queue_push_tail (res, cp);
}
/**
@@ -621,7 +621,7 @@ _append_control_point (GstControlPoint * cp, GList ** l)
GList *
gst_interpolation_control_source_get_all (GstInterpolationControlSource * self)
{
- GList *res = NULL;
+ GQueue res = G_QUEUE_INIT;
g_return_val_if_fail (GST_IS_INTERPOLATION_CONTROL_SOURCE (self), NULL);
@@ -631,7 +631,7 @@ gst_interpolation_control_source_get_all (GstInterpolationControlSource * self)
&res);
g_mutex_unlock (self->lock);
- return g_list_reverse (res);
+ return res.head;
}
/**