gobject: avoid calling g_weak_ref_set() when intializing GWeakRef to NULL

If object is NULL, g_weak_ref_set() really does nothing. However,
it will pointlessly take a lock, before deciding to do nothing.
Avoid that.
This commit is contained in:
Thomas Haller 2023-12-21 21:27:51 +01:00
parent de5e26e2ed
commit aaf4ccb901

View File

@ -5001,7 +5001,8 @@ g_weak_ref_init (GWeakRef *weak_ref,
{
weak_ref->priv.p = NULL;
g_weak_ref_set (weak_ref, object);
if (object)
g_weak_ref_set (weak_ref, object);
}
/**