[glib/gobject-performance: 3/10] Allocate GObjectNotifyQueue with g_slice instead of abusing g_list
- From: Alexander Larsson <alexl src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [glib/gobject-performance: 3/10] Allocate GObjectNotifyQueue with g_slice instead of abusing g_list
- Date: Wed, 9 Sep 2009 15:24:02 +0000 (UTC)
commit 34b206809f92d2935d5ae54212311d935152366a
Author: Alexander Larsson <alexl redhat com>
Date: Wed Aug 19 15:48:19 2009 +0200
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
gobject/gobjectnotifyqueue.c | 9 ++-------
1 files changed, 2 insertions(+), 7 deletions(-)
---
diff --git a/gobject/gobjectnotifyqueue.c b/gobject/gobjectnotifyqueue.c
index 1d5787b..e57714f 100644
--- a/gobject/gobjectnotifyqueue.c
+++ b/gobject/gobjectnotifyqueue.c
@@ -48,12 +48,8 @@ struct _GObjectNotifyQueue
GSList *pspecs;
guint16 n_pspecs;
guint16 freeze_count;
- /* currently, this structure abuses the GList allocation chain and thus
- * must be <= sizeof (GList)
- */
};
-
/* --- functions --- */
static void
g_object_notify_queue_free (gpointer data)
@@ -61,7 +57,7 @@ g_object_notify_queue_free (gpointer data)
GObjectNotifyQueue *nqueue = data;
g_slist_free (nqueue->pspecs);
- g_list_free_1 ((void*) nqueue);
+ g_slice_free (GObjectNotifyQueue, (void*) nqueue);
}
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);
if (!nqueue)
{
- nqueue = (void*) g_list_alloc ();
- memset (nqueue, 0, sizeof (*nqueue));
+ nqueue = (void*) g_slice_new0 (GObjectNotifyQueue);
nqueue->context = context;
g_datalist_id_set_data_full (&object->qdata, context->quark_notify_queue,
nqueue, g_object_notify_queue_free);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]