mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-22 04:22:29 +00:00
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 */
|
/* 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
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -82,29 +85,32 @@ struct _ArrayList
|
||||||
guint arraylength;
|
guint arraylength;
|
||||||
gboolean owned;
|
gboolean owned;
|
||||||
ArrayList *next;
|
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
|
static void
|
||||||
add_to_list (ArrayList *list,
|
add_to_list (ArrayList *list,
|
||||||
lab *array,
|
lab *array,
|
||||||
guint arraylength,
|
guint arraylength,
|
||||||
gboolean take)
|
gboolean take)
|
||||||
{
|
{
|
||||||
ArrayList *cur = list;
|
ArrayList *tail = list->tail;
|
||||||
ArrayList *prev;
|
|
||||||
|
|
||||||
do
|
tail->array = array;
|
||||||
{
|
tail->arraylength = arraylength;
|
||||||
prev = cur;
|
tail->owned = take;
|
||||||
cur = cur->next;
|
|
||||||
}
|
|
||||||
while (cur);
|
|
||||||
|
|
||||||
prev->next = g_new0 (ArrayList, 1);
|
list->tail = tail->next = g_new0 (ArrayList, 1);
|
||||||
|
|
||||||
prev->array = array;
|
|
||||||
prev->arraylength = arraylength;
|
|
||||||
prev->owned = take;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -510,7 +516,7 @@ create_signature (lab *input,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
clusters1 = g_new0 (ArrayList, 1);
|
clusters1 = list_new ();
|
||||||
|
|
||||||
stageone (input, SIOX_DIMS, 0, clusters1, limits, length);
|
stageone (input, SIOX_DIMS, 0, clusters1, limits, length);
|
||||||
clusters1size = list_size (clusters1);
|
clusters1size = list_size (clusters1);
|
||||||
|
@ -545,7 +551,7 @@ create_signature (lab *input,
|
||||||
g_printerr ("step #1 -> %d clusters\n", clusters1size);
|
g_printerr ("step #1 -> %d clusters\n", clusters1size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
clusters2 = g_new0 (ArrayList, 1);
|
clusters2 = list_new ();
|
||||||
|
|
||||||
stagetwo (centroids,
|
stagetwo (centroids,
|
||||||
SIOX_DIMS, 0, clusters2, limits, clusters1size, length,
|
SIOX_DIMS, 0, clusters2, limits, clusters1size, length,
|
||||||
|
|
Loading…
Reference in a new issue