mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 01:30:38 +00:00
uri: Build doubly-linked list by prepending items
As outlined in the API documentation, g_list_append() iterates over the whole list, which can quickly introduce performance issues when the list becomes very big, such as for data URIs for instance. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1983>
This commit is contained in:
parent
8ae3c584d0
commit
842c59a4b6
1 changed files with 3 additions and 3 deletions
|
@ -1315,7 +1315,7 @@ _gst_uri_string_to_list (const gchar * str, const gchar * sep, gboolean convert,
|
||||||
for (next_elem = split_str; *next_elem; next_elem += 1) {
|
for (next_elem = split_str; *next_elem; next_elem += 1) {
|
||||||
gchar *elem = *next_elem;
|
gchar *elem = *next_elem;
|
||||||
if (*elem == '\0') {
|
if (*elem == '\0') {
|
||||||
new_list = g_list_append (new_list, NULL);
|
new_list = g_list_prepend (new_list, NULL);
|
||||||
} else {
|
} else {
|
||||||
if (convert && !unescape) {
|
if (convert && !unescape) {
|
||||||
gchar *next_sep;
|
gchar *next_sep;
|
||||||
|
@ -1331,7 +1331,7 @@ _gst_uri_string_to_list (const gchar * str, const gchar * sep, gboolean convert,
|
||||||
g_free (elem);
|
g_free (elem);
|
||||||
elem = *next_elem;
|
elem = *next_elem;
|
||||||
}
|
}
|
||||||
new_list = g_list_append (new_list, g_strdup (elem));
|
new_list = g_list_prepend (new_list, g_strdup (elem));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1340,7 +1340,7 @@ _gst_uri_string_to_list (const gchar * str, const gchar * sep, gboolean convert,
|
||||||
g_free (pct_sep);
|
g_free (pct_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new_list;
|
return g_list_reverse (new_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GHashTable *
|
static GHashTable *
|
||||||
|
|
Loading…
Reference in a new issue