mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-13 15:56:23 +01:00
gobject: Avoid the ref/unref dance if assigning the same to a value
g_value_set_object could lead to perform unneeded ref/unref operations in case we were trying to set again an object to a GValue
This commit is contained in:
parent
cbee90b8a4
commit
bc59ed8fba
@ -4502,6 +4502,9 @@ g_value_set_object (GValue *value,
|
||||
|
||||
g_return_if_fail (G_VALUE_HOLDS_OBJECT (value));
|
||||
|
||||
if G_UNLIKELY (value->data[0].v_pointer == v_object)
|
||||
return;
|
||||
|
||||
old = value->data[0].v_pointer;
|
||||
|
||||
if (v_object)
|
||||
|
@ -719,6 +719,7 @@ test_value_transform_object (void)
|
||||
|
||||
g_value_init (&src, types[s]);
|
||||
g_value_set_object (&src, object);
|
||||
g_value_set_object (&src, g_value_get_object (&src));
|
||||
|
||||
for (d = 0; d < G_N_ELEMENTS (types); d++)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user