From 34abe02458b7882e27c309217b03952b2cda0b93 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 16 Sep 2010 00:37:59 +0100 Subject: [PATCH] query: minor gst_query_add_buffering_range() code reflow Sprinkle some G_UNLIKELY(), return TRUE/FALSE constants, avoid an unnecessary g_value_unset(), move g_value_init()+set_int64_range() closer to where they're needed. --- gst/gstquery.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/gst/gstquery.c b/gst/gstquery.c index 411b2a1..44ffa59 100644 --- a/gst/gstquery.c +++ b/gst/gstquery.c @@ -1303,23 +1303,19 @@ gst_query_add_buffering_range (GstQuery * query, gint64 start, gint64 stop) GValue *last_array_value; const GValue *value; GValue range_value = { 0 }; - gboolean ret = FALSE; - - g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERING, ret); - if (start >= stop) - return ret; + g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERING, FALSE); - g_value_init (&range_value, GST_TYPE_INT64_RANGE); - gst_value_set_int64_range (&range_value, start, stop); + if (G_UNLIKELY (start >= stop)) + return FALSE; structure = gst_query_get_structure (query); value = gst_structure_id_get_value (structure, GST_QUARK (BUFFERING_RANGES)); if (value) { array = (GValueArray *) g_value_get_boxed (value); last_array_value = g_value_array_get_nth (array, array->n_values - 1); - if (start > gst_value_get_int64_range_min (last_array_value)) - ret = TRUE; + if (G_UNLIKELY (start <= gst_value_get_int64_range_min (last_array_value))) + return FALSE; } else { GValue new_array_val = { 0, }; @@ -1332,17 +1328,14 @@ gst_query_add_buffering_range (GstQuery * query, gint64 start, gint64 stop) * existing value array owned by the GstStructure / the field's GValue */ gst_structure_id_take_value (structure, GST_QUARK (BUFFERING_RANGES), &new_array_val); - - ret = TRUE; - } - - if (ret) { - g_value_array_append (array, &range_value); } - g_value_unset (&range_value); + g_value_init (&range_value, GST_TYPE_INT64_RANGE); + gst_value_set_int64_range (&range_value, start, stop); + g_value_array_append (array, &range_value); + /* skip the g_value_unset(&range_value) here, we know it's not needed */ - return ret; + return TRUE; } /** -- 2.7.4