[glib: 1/2] gobject: Small speedup in weak-ref-set
- From: Marco Trevisan <marcotrevi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/2] gobject: Small speedup in weak-ref-set
- Date: Fri, 8 Jul 2022 14:37:54 +0000 (UTC)
commit 3290ebfadc5976755a4dba30592cb9b5a954e911
Author: Peter Bloomfield <peterbloomfield bellsouth net>
Date: Fri Jul 8 14:37:53 2022 +0000
gobject: Small speedup in weak-ref-set
gobject/gobject.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
---
diff --git a/gobject/gobject.c b/gobject/gobject.c
index 07ff404ce8..f743e589ad 100644
--- a/gobject/gobject.c
+++ b/gobject/gobject.c
@@ -5053,14 +5053,16 @@ g_weak_ref_set (GWeakRef *weak_ref,
/* Remove the weak ref from the old object */
if (old_object != NULL)
{
- gboolean in_weak_refs_notify;
-
weak_locations = g_datalist_id_get_data (&old_object->qdata, quark_weak_locations);
- in_weak_refs_notify = g_datalist_id_get_data (&old_object->qdata, quark_weak_refs) == NULL;
- /* for it to point to an object, the object must have had it added once */
- g_assert (weak_locations != NULL || in_weak_refs_notify);
-
- if (weak_locations != NULL)
+ if (weak_locations == NULL)
+ {
+#ifndef G_DISABLE_ASSERT
+ gboolean in_weak_refs_notify =
+ g_datalist_id_get_data (&old_object->qdata, quark_weak_refs) == NULL;
+ g_assert (in_weak_refs_notify);
+#endif /* G_DISABLE_ASSERT */
+ }
+ else
{
*weak_locations = g_slist_remove (*weak_locations, weak_ref);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]