From: Jan Alexander Steffens (heftig) Date: Fri, 29 Jul 2022 09:53:18 +0000 (+0200) Subject: srt: Use simpler list operations for callers X-Git-Tag: 1.22.0~610 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d575a4114588fbd1bdb1cd68d6db7ce8c4dceb2c;p=platform%2Fupstream%2Fgstreamer.git srt: Use simpler list operations for callers Avoid `g_list_append` and `g_list_remove` (which have to scan the list) and replace them with `g_list_prepend` and `g_list_delete_link`. Part-of: --- diff --git a/subprojects/gst-plugins-bad/ext/srt/gstsrtobject.c b/subprojects/gst-plugins-bad/ext/srt/gstsrtobject.c index 049be1d..349b3e5 100644 --- a/subprojects/gst-plugins-bad/ext/srt/gstsrtobject.c +++ b/subprojects/gst-plugins-bad/ext/srt/gstsrtobject.c @@ -973,7 +973,7 @@ thread_func (gpointer data) caller->sock); g_mutex_lock (&srtobject->sock_lock); - srtobject->callers = g_list_append (srtobject->callers, caller); + srtobject->callers = g_list_prepend (srtobject->callers, caller); g_cond_signal (&srtobject->sock_cond); g_mutex_unlock (&srtobject->sock_lock); @@ -1661,18 +1661,17 @@ gst_srt_object_write_to_callers (GstSRTObject * srtobject, GstBufferList * headers, const GstMapInfo * mapinfo, GCancellable * cancellable) { - GList *callers; + GList *item, *next; g_mutex_lock (&srtobject->sock_lock); - callers = srtobject->callers; - while (callers != NULL) { + for (item = srtobject->callers, next = NULL; item; item = next) { + SRTCaller *caller = item->data; gssize len = 0; const guint8 *msg = mapinfo->data; gint sent; gint payload_size, optlen = sizeof (payload_size); - SRTCaller *caller = callers->data; - callers = callers->next; + next = item->next; if (g_cancellable_is_cancelled (cancellable)) { goto cancelled; @@ -1714,7 +1713,7 @@ gst_srt_object_write_to_callers (GstSRTObject * srtobject, continue; err: - srtobject->callers = g_list_remove (srtobject->callers, caller); + srtobject->callers = g_list_delete_link (srtobject->callers, item); srt_caller_signal_removed (caller, srtobject); srt_caller_free (caller); }