From c4ff06986442fe50f424161220ccb31db758b797 Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Tue, 27 Mar 2018 10:15:46 +0200 Subject: [PATCH] gstinfo: Simplify gst_debug_reset_threshold() implementation Replace the while+goto with a for+break and check walk to determine whether we had a match. Move up the unlock to keep the locked section as small as possible. https://bugzilla.gnome.org/show_bug.cgi?id=794717 --- gst/gstinfo.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/gst/gstinfo.c b/gst/gstinfo.c index 63857ce..b1d86f0 100644 --- a/gst/gstinfo.c +++ b/gst/gstinfo.c @@ -1598,18 +1598,16 @@ gst_debug_reset_threshold (gpointer category, gpointer unused) GSList *walk; g_mutex_lock (&__level_name_mutex); - walk = __level_name; - while (walk) { - LevelNameEntry *entry = walk->data; - walk = g_slist_next (walk); - if (gst_debug_apply_entry (cat, entry)) - goto exit; + for (walk = __level_name; walk != NULL; walk = walk->next) { + if (gst_debug_apply_entry (cat, walk->data)) + break; } - gst_debug_category_set_threshold (cat, gst_debug_get_default_threshold ()); -exit: g_mutex_unlock (&__level_name_mutex); + + if (walk == NULL) + gst_debug_category_set_threshold (cat, gst_debug_get_default_threshold ()); } static void -- 2.7.4