mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-21 22:59:16 +02:00
Allocate GObjectNotifyQueue with g_slice instead of abusing g_list
This is both cleaner and faster (it avoids function calls and zeroing the memory twice). Object construction performance improvement: Non-Threaded Threaded Simple: 11% 1.3% Complex: 8% 6% Other tests stable. https://bugzilla.gnome.org/show_bug.cgi?id=557100
This commit is contained in:
parent
f4d9789fcf
commit
af017accc5
@ -48,12 +48,8 @@ struct _GObjectNotifyQueue
|
|||||||
GSList *pspecs;
|
GSList *pspecs;
|
||||||
guint16 n_pspecs;
|
guint16 n_pspecs;
|
||||||
guint16 freeze_count;
|
guint16 freeze_count;
|
||||||
/* currently, this structure abuses the GList allocation chain and thus
|
|
||||||
* must be <= sizeof (GList)
|
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* --- functions --- */
|
/* --- functions --- */
|
||||||
static void
|
static void
|
||||||
g_object_notify_queue_free (gpointer data)
|
g_object_notify_queue_free (gpointer data)
|
||||||
@ -61,7 +57,7 @@ g_object_notify_queue_free (gpointer data)
|
|||||||
GObjectNotifyQueue *nqueue = data;
|
GObjectNotifyQueue *nqueue = data;
|
||||||
|
|
||||||
g_slist_free (nqueue->pspecs);
|
g_slist_free (nqueue->pspecs);
|
||||||
g_list_free_1 ((void*) nqueue);
|
g_slice_free (GObjectNotifyQueue, nqueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline GObjectNotifyQueue*
|
static inline GObjectNotifyQueue*
|
||||||
@ -73,8 +69,7 @@ g_object_notify_queue_freeze (GObject *object,
|
|||||||
nqueue = g_datalist_id_get_data (&object->qdata, context->quark_notify_queue);
|
nqueue = g_datalist_id_get_data (&object->qdata, context->quark_notify_queue);
|
||||||
if (!nqueue)
|
if (!nqueue)
|
||||||
{
|
{
|
||||||
nqueue = (void*) g_list_alloc ();
|
nqueue = g_slice_new0 (GObjectNotifyQueue);
|
||||||
memset (nqueue, 0, sizeof (*nqueue));
|
|
||||||
nqueue->context = context;
|
nqueue->context = context;
|
||||||
g_datalist_id_set_data_full (&object->qdata, context->quark_notify_queue,
|
g_datalist_id_set_data_full (&object->qdata, context->quark_notify_queue,
|
||||||
nqueue, g_object_notify_queue_free);
|
nqueue, g_object_notify_queue_free);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user