gobject: Use g_datalist_id_remove_multiple

This speeds up object finalization a little.
This commit is contained in:
Matthias Clasen 2022-05-22 07:22:16 -04:00
parent 0415bf9412
commit fa8c7c0da6

View File

@ -1181,10 +1181,14 @@ g_object_do_get_property (GObject *object,
static void static void
g_object_real_dispose (GObject *object) g_object_real_dispose (GObject *object)
{ {
GQuark keys[3] = {
quark_closure_array,
quark_weak_refs,
quark_weak_locations,
};
g_signal_handlers_destroy (object); g_signal_handlers_destroy (object);
g_datalist_id_set_data (&object->qdata, quark_closure_array, NULL); g_datalist_id_remove_multiple (&object->qdata, keys, G_N_ELEMENTS (keys));
g_datalist_id_set_data (&object->qdata, quark_weak_refs, NULL);
g_datalist_id_set_data (&object->qdata, quark_weak_locations, NULL);
} }
#ifdef G_ENABLE_DEBUG #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 */ /* 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_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 */ /* decrement the last reference */
old_ref = g_atomic_int_add (&object->ref_count, -1); old_ref = g_atomic_int_add (&object->ref_count, -1);