From aaf4ccb9013ae45ce7e7c0353bd304c8c0edc012 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 21 Dec 2023 21:27:51 +0100 Subject: [PATCH] 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. --- gobject/gobject.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gobject/gobject.c b/gobject/gobject.c index e52bf5727..b098c33cc 100644 --- a/gobject/gobject.c +++ b/gobject/gobject.c @@ -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); } /**