Commit 9dfb56a4 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

keep a tail pointer. Speeds up the benchmark by about 50%.

2005-07-29  Sven Neumann  <sven@gimp.org>

	* app/base/siox.c (add_to_list): keep a tail pointer. Speeds up
	the benchmark by about 50%.
parent ab2bff88
......@@ -64,7 +64,10 @@
/* Simulate a java.util.ArrayList */
/* These methods are NOT generic */
/* Could be improved. At the moment we are wasting a node per list and
* the tail pointer on each node is only used in the first node.
*/
typedef struct
{
......@@ -82,29 +85,32 @@ struct _ArrayList
guint arraylength;
gboolean owned;
ArrayList *next;
ArrayList *tail; /* only valid in the root item */
};
static ArrayList *
list_new (void)
{
ArrayList *list = g_new0 (ArrayList, 1);
list->tail = list;
return list;
}
static void
add_to_list (ArrayList *list,
lab *array,
guint arraylength,
gboolean take)
{
ArrayList *cur = list;
ArrayList *prev;
do
{
prev = cur;
cur = cur->next;
}
while (cur);
ArrayList *tail = list->tail;
prev->next = g_new0 (ArrayList, 1);
tail->array = array;
tail->arraylength = arraylength;
tail->owned = take;
prev->array = array;
prev->arraylength = arraylength;
prev->owned = take;
list->tail = tail->next = g_new0 (ArrayList, 1);
}
static int
......@@ -510,7 +516,7 @@ create_signature (lab *input,
return NULL;
}
clusters1 = g_new0 (ArrayList, 1);
clusters1 = list_new ();
stageone (input, SIOX_DIMS, 0, clusters1, limits, length);
clusters1size = list_size (clusters1);
......@@ -545,7 +551,7 @@ create_signature (lab *input,
g_printerr ("step #1 -> %d clusters\n", clusters1size);
#endif
clusters2 = g_new0 (ArrayList, 1);
clusters2 = list_new ();
stagetwo (centroids,
SIOX_DIMS, 0, clusters2, limits, clusters1size, length,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment