gobject: Avoid redundant atomics

According to the commit that introduced these
calls (4b334ef8f1), we are checking
the refcount here to avoid calling g_object_ref
when the refcount is 0, in the rare case that
notification would be triggered during finalize.

But we are now freezing notifications during
finalize, and after recent changes, we no longer call
g_object_ref for notification while a freeze is
in place.
This commit is contained in:
Matthias Clasen 2022-05-29 18:50:22 -04:00
parent 2b437402e8
commit 16a8b6d819

View File

@ -319,8 +319,6 @@ g_object_notify_queue_thaw (GObject *object,
GSList *slist; GSList *slist;
guint n_pspecs = 0; guint n_pspecs = 0;
g_return_if_fail (g_atomic_int_get(&object->ref_count) > 0);
G_LOCK(notify_lock); G_LOCK(notify_lock);
/* Just make sure we never get into some nasty race condition */ /* Just make sure we never get into some nasty race condition */
@ -1378,8 +1376,6 @@ g_object_notify (GObject *object,
g_return_if_fail (G_IS_OBJECT (object)); g_return_if_fail (G_IS_OBJECT (object));
g_return_if_fail (property_name != NULL); g_return_if_fail (property_name != NULL);
if (g_atomic_int_get (&object->ref_count) == 0)
return;
/* We don't need to get the redirect target /* We don't need to get the redirect target
* (by, e.g. calling g_object_class_find_property()) * (by, e.g. calling g_object_class_find_property())
@ -1452,9 +1448,6 @@ g_object_notify_by_pspec (GObject *object,
g_return_if_fail (G_IS_OBJECT (object)); g_return_if_fail (G_IS_OBJECT (object));
g_return_if_fail (G_IS_PARAM_SPEC (pspec)); g_return_if_fail (G_IS_PARAM_SPEC (pspec));
if (g_atomic_int_get (&object->ref_count) == 0)
return;
g_object_notify_by_spec_internal (object, pspec); g_object_notify_by_spec_internal (object, pspec);
} }