mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-20 04:56:24 +00:00
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:
parent
d5d6e6cfdd
commit
40eb462591
1 changed files with 5 additions and 6 deletions
|
@ -722,16 +722,15 @@ rtp_session_create_sources (RTPSession * sess)
|
||||||
static void
|
static void
|
||||||
create_source_stats (gpointer key, RTPSource * source, GValueArray * arr)
|
create_source_stats (gpointer key, RTPSource * source, GValueArray * arr)
|
||||||
{
|
{
|
||||||
GValue value = G_VALUE_INIT;
|
GValue *value;
|
||||||
GstStructure *s;
|
GstStructure *s;
|
||||||
|
|
||||||
g_object_get (source, "stats", &s, NULL);
|
g_object_get (source, "stats", &s, NULL);
|
||||||
|
|
||||||
g_value_init (&value, GST_TYPE_STRUCTURE);
|
g_value_array_append (arr, NULL);
|
||||||
gst_value_set_structure (&value, s);
|
value = g_value_array_get_nth (arr, arr->n_values - 1);
|
||||||
g_value_array_append (arr, &value);
|
g_value_init (value, GST_TYPE_STRUCTURE);
|
||||||
gst_structure_free (s);
|
g_value_take_boxed (value, s);
|
||||||
g_value_unset (&value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstStructure *
|
static GstStructure *
|
||||||
|
|
Loading…
Reference in a new issue