mirror of https://github.com/GNOME/gimp.git
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%.
This commit is contained in:
parent
ab2bff88de
commit
9dfb56a435
|
@ -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;
|
||||
ArrayList *tail = list->tail;
|
||||
|
||||
do
|
||||
{
|
||||
prev = cur;
|
||||
cur = cur->next;
|
||||
}
|
||||
while (cur);
|
||||
tail->array = array;
|
||||
tail->arraylength = arraylength;
|
||||
tail->owned = take;
|
||||
|
||||
prev->next = g_new0 (ArrayList, 1);
|
||||
|
||||
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,
|
||||
|
|
Loading…
Reference in New Issue