mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-18 13:25:56 +00:00
caps, structure, taglist: micro-optimisations
Avoid some unnecessary GValue copying by making use of gst_structure_id_take_value() where possible.
This commit is contained in:
parent
172011d1f5
commit
22036ef1c4
3 changed files with 9 additions and 15 deletions
|
@ -1350,8 +1350,7 @@ gst_caps_structure_subtract_field (GQuark field_id, const GValue * value,
|
|||
return FALSE;
|
||||
} else {
|
||||
structure = gst_structure_copy (e->subtract_from);
|
||||
gst_structure_id_set_value (structure, field_id, &subtraction);
|
||||
g_value_unset (&subtraction);
|
||||
gst_structure_id_take_value (structure, field_id, &subtraction);
|
||||
e->put_into = g_slist_prepend (e->put_into, structure);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1488,9 +1487,7 @@ gst_caps_normalize_foreach (GQuark field_id, const GValue * value, gpointer ptr)
|
|||
}
|
||||
|
||||
gst_value_init_and_copy (&val, gst_value_list_get_value (value, 0));
|
||||
gst_structure_id_set_value (nf->structure, field_id, &val);
|
||||
g_value_unset (&val);
|
||||
|
||||
gst_structure_id_take_value (nf->structure, field_id, &val);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -1611,11 +1608,12 @@ gst_caps_structure_simplify (GstStructure ** result,
|
|||
* but at most one field: field.name */
|
||||
if (G_IS_VALUE (&field.value)) {
|
||||
if (gst_structure_n_fields (simplify) == gst_structure_n_fields (compare)) {
|
||||
gst_structure_id_set_value (compare, field.name, &field.value);
|
||||
gst_structure_id_take_value (compare, field.name, &field.value);
|
||||
*result = NULL;
|
||||
ret = TRUE;
|
||||
} else {
|
||||
g_value_unset (&field.value);
|
||||
}
|
||||
g_value_unset (&field.value);
|
||||
} else if (gst_structure_n_fields (simplify) <=
|
||||
gst_structure_n_fields (compare)) {
|
||||
/* compare is just more specific, will be optimized away later */
|
||||
|
|
|
@ -2687,8 +2687,7 @@ default_fixate (GQuark field_id, const GValue * value, gpointer data)
|
|||
GValue v = { 0 };
|
||||
|
||||
if (gst_value_fixate (&v, value)) {
|
||||
gst_structure_id_set_value (s, field_id, &v);
|
||||
g_value_unset (&v);
|
||||
gst_structure_id_take_value (s, field_id, &v);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -3023,8 +3022,7 @@ gst_structure_intersect_field1 (GQuark id, const GValue * val1, gpointer data)
|
|||
} else {
|
||||
GValue dest_value = { 0 };
|
||||
if (gst_value_intersect (&dest_value, val1, val2)) {
|
||||
gst_structure_id_set_value (idata->dest, id, &dest_value);
|
||||
g_value_unset (&dest_value);
|
||||
gst_structure_id_take_value (idata->dest, id, &dest_value);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -1026,13 +1026,11 @@ gst_tag_list_add_value_internal (GstTagList * tag_list, GstTagMergeMode mode,
|
|||
break;
|
||||
case GST_TAG_MERGE_PREPEND:
|
||||
gst_value_list_merge (&dest, value, value2);
|
||||
gst_structure_id_set_value (list, tag_quark, &dest);
|
||||
g_value_unset (&dest);
|
||||
gst_structure_id_take_value (list, tag_quark, &dest);
|
||||
break;
|
||||
case GST_TAG_MERGE_APPEND:
|
||||
gst_value_list_merge (&dest, value2, value);
|
||||
gst_structure_id_set_value (list, tag_quark, &dest);
|
||||
g_value_unset (&dest);
|
||||
gst_structure_id_take_value (list, tag_quark, &dest);
|
||||
break;
|
||||
case GST_TAG_MERGE_KEEP:
|
||||
case GST_TAG_MERGE_KEEP_ALL:
|
||||
|
|
Loading…
Reference in a new issue