[glib/finalize-speedups: 9/11] gobject: Use g_datalist_id_remove_multiple
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/finalize-speedups: 9/11] gobject: Use g_datalist_id_remove_multiple
- Date: Mon, 23 May 2022 12:52:19 +0000 (UTC)
commit b7ea3efa97a7c3a0ebc00a7967c67ad9799ef70e
Author: Matthias Clasen <mclasen redhat com>
Date: Sun May 22 07:22:16 2022 -0400
gobject: Use g_datalist_id_remove_multiple
This speeds up object finalization a little.
gobject/gobject.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/gobject/gobject.c b/gobject/gobject.c
index 4c992d3619..e710afc292 100644
--- a/gobject/gobject.c
+++ b/gobject/gobject.c
@@ -1181,10 +1181,14 @@ g_object_do_get_property (GObject *object,
static void
g_object_real_dispose (GObject *object)
{
+ GQuark keys[3] = {
+ quark_closure_array,
+ quark_weak_refs,
+ quark_weak_locations,
+ };
+
g_signal_handlers_destroy (object);
- g_datalist_id_set_data (&object->qdata, quark_closure_array, NULL);
- g_datalist_id_set_data (&object->qdata, quark_weak_refs, NULL);
- g_datalist_id_set_data (&object->qdata, quark_weak_locations, NULL);
+ g_datalist_id_remove_multiple (&object->qdata, keys, G_N_ELEMENTS (keys));
}
#ifdef G_ENABLE_DEBUG
@@ -3678,10 +3682,15 @@ g_object_unref (gpointer _object)
}
/* we are still in the process of taking away the last ref */
- g_datalist_id_set_data (&object->qdata, quark_closure_array, NULL);
g_signal_handlers_destroy (object);
- g_datalist_id_set_data (&object->qdata, quark_weak_refs, NULL);
- g_datalist_id_set_data (&object->qdata, quark_weak_locations, NULL);
+ {
+ GQuark keys[3] = {
+ quark_closure_array,
+ quark_weak_refs,
+ quark_weak_locations,
+ };
+ g_datalist_id_remove_multiple (&object->qdata, keys, G_N_ELEMENTS (keys));
+ }
/* decrement the last reference */
old_ref = g_atomic_int_add (&object->ref_count, -1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]