From 420dacb2d581521f147868ef3419a0ab1d3ed25a Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Wed, 19 Jun 2013 09:22:50 +0200 Subject: [PATCH] xmptag: More efficient GSList usage Instead of constantly appending (which gets more and more expensive), just prepend to the list (O(1)) and reverse the list before usage. https://bugzilla.gnome.org/show_bug.cgi?id=702545 --- gst-libs/gst/tag/gstxmptag.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gst-libs/gst/tag/gstxmptag.c b/gst-libs/gst/tag/gstxmptag.c index 56890ce3bd..d127e8c57d 100644 --- a/gst-libs/gst/tag/gstxmptag.c +++ b/gst-libs/gst/tag/gstxmptag.c @@ -1338,7 +1338,7 @@ gst_tag_list_from_xmp_buffer (GstBuffer * buffer) ptag->xmp_tag = xmp_tag; ptag->str = g_strdup (v); - pending_tags = g_slist_append (pending_tags, ptag); + pending_tags = g_slist_prepend (pending_tags, ptag); } } /* restore chars overwritten by '\0' */ @@ -1431,7 +1431,7 @@ gst_tag_list_from_xmp_buffer (GstBuffer * buffer) ptag->xmp_tag = last_xmp_tag; ptag->str = g_strdup (part); - pending_tags = g_slist_append (pending_tags, ptag); + pending_tags = g_slist_prepend (pending_tags, ptag); } } } @@ -1442,6 +1442,10 @@ gst_tag_list_from_xmp_buffer (GstBuffer * buffer) } } + pending_tags = g_slist_reverse (pending_tags); + + GST_DEBUG ("Done accumulating tags, now handling them"); + while (pending_tags) { PendingXmpTag *ptag = (PendingXmpTag *) pending_tags->data;