rtpsession: Avoid unnecessary copy of stats structure

The code before copied GstStructure twice. The first time inside
gst_value_set_structure and the second time in g_value_array_append.
Optimized version does no copies, just transfers ownership to
GValueArray. It takes advantage of the fact that array has already
enough elements preallocated and the memory is zero initialized.

https://bugzilla.gnome.org/show_bug.cgi?id=795139
This commit is contained in:
Mikhail Fludkov 2016-10-06 16:08:38 +02:00 committed by Tim-Philipp Müller
parent d5d6e6cfdd
commit 40eb462591

View file

@ -722,16 +722,15 @@ rtp_session_create_sources (RTPSession * sess)
static void
create_source_stats (gpointer key, RTPSource * source, GValueArray * arr)
{
GValue value = G_VALUE_INIT;
GValue *value;
GstStructure *s;
g_object_get (source, "stats", &s, NULL);
g_value_init (&value, GST_TYPE_STRUCTURE);
gst_value_set_structure (&value, s);
g_value_array_append (arr, &value);
gst_structure_free (s);
g_value_unset (&value);
g_value_array_append (arr, NULL);
value = g_value_array_get_nth (arr, arr->n_values - 1);
g_value_init (value, GST_TYPE_STRUCTURE);
g_value_take_boxed (value, s);
}
static GstStructure *