[sysprof] Add a cache for TreeDataList allocation
- From: Søren Sandmann Pedersen <ssp src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [sysprof] Add a cache for TreeDataList allocation
- Date: Mon, 14 Sep 2009 09:07:01 +0000 (UTC)
commit f368efaaf01de2914487b091c099b54b6f2483bd
Author: Søren Sandmann Pedersen <ssp redhat com>
Date: Mon Aug 17 07:38:15 2009 -0400
Add a cache for TreeDataList allocation
footreedatalist.c | 26 ++++++++++++++++++++++++--
1 files changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/footreedatalist.c b/footreedatalist.c
index be169ba..21e4874 100644
--- a/footreedatalist.c
+++ b/footreedatalist.c
@@ -23,15 +23,35 @@
#include "footreedatalist.h"
#include <string.h>
+static FooTreeDataList *cache;
+
/* node allocation
*/
+#define N_DATA_LISTS (64)
+
FooTreeDataList *
_foo_tree_data_list_alloc (void)
{
FooTreeDataList *list;
- list = g_slice_new0 (FooTreeDataList);
+ if (!cache)
+ {
+ int i;
+
+ list = g_malloc (N_DATA_LISTS * sizeof (FooTreeDataList));
+ for (i = 0; i < N_DATA_LISTS; ++i)
+ {
+ list[i].next = cache;
+ cache = &(list[i]);
+ }
+ }
+
+ list = cache;
+ cache = cache->next;
+
+ memset (list, 0, sizeof (FooTreeDataList));
+
return list;
}
@@ -54,7 +74,9 @@ _foo_tree_data_list_free (FooTreeDataList *list,
else if (g_type_is_a (column_headers [i], G_TYPE_BOXED) && tmp->data.v_pointer != NULL)
g_boxed_free (column_headers [i], (gpointer) tmp->data.v_pointer);
- g_slice_free (FooTreeDataList, tmp);
+ tmp->next = cache;
+ cache = tmp;
+
i++;
tmp = next;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]