mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-02 07:23:41 +02: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:
@@ -4502,8 +4502,11 @@ 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)
|
||||
{
|
||||
g_return_if_fail (G_IS_OBJECT (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++)
|
||||
{
|
||||
|
Reference in New Issue
Block a user