mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-11 23:51:06 +00:00
Add a cache for TreeDataList allocation
This commit is contained in:
@ -23,14 +23,34 @@
|
|||||||
#include "footreedatalist.h"
|
#include "footreedatalist.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
static FooTreeDataList *cache;
|
||||||
|
|
||||||
/* node allocation
|
/* node allocation
|
||||||
*/
|
*/
|
||||||
|
#define N_DATA_LISTS (64)
|
||||||
|
|
||||||
FooTreeDataList *
|
FooTreeDataList *
|
||||||
_foo_tree_data_list_alloc (void)
|
_foo_tree_data_list_alloc (void)
|
||||||
{
|
{
|
||||||
FooTreeDataList *list;
|
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;
|
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)
|
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_boxed_free (column_headers [i], (gpointer) tmp->data.v_pointer);
|
||||||
|
|
||||||
g_slice_free (FooTreeDataList, tmp);
|
tmp->next = cache;
|
||||||
|
cache = tmp;
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
tmp = next;
|
tmp = next;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user