From: Philippe Normand Date: Thu, 10 Mar 2022 18:22:49 +0000 (+0000) Subject: uri: Build doubly-linked list by prepending items X-Git-Tag: 1.22.0~2129 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4277af3219cc68853a49537e39aa0c1caefc5356;p=platform%2Fupstream%2Fgstreamer.git 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: --- diff --git a/subprojects/gstreamer/gst/gsturi.c b/subprojects/gstreamer/gst/gsturi.c index de61365..d3501a8 100644 --- a/subprojects/gstreamer/gst/gsturi.c +++ b/subprojects/gstreamer/gst/gsturi.c @@ -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) { gchar *elem = *next_elem; if (*elem == '\0') { - new_list = g_list_append (new_list, NULL); + new_list = g_list_prepend (new_list, NULL); } else { if (convert && !unescape) { gchar *next_sep; @@ -1331,7 +1331,7 @@ _gst_uri_string_to_list (const gchar * str, const gchar * sep, gboolean convert, g_free (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); } - return new_list; + return g_list_reverse (new_list); } static GHashTable *