Major speed hacks



I did two speed hacks today.

The first is my g_list_travel_to_nth in tny-msg-header-list-model.c. The
idea here is simple: I already know the current location. So traveling
to a new location can very often go much faster than each time starting
from zero. This significantly speeds the default sorting algorithms of
the GtkTreeView stack up. You'll notice speed differences in seconds
when sorting large folders.

static GList*
g_list_travel_to_nth (GList *list, guint cur, guint nth)
{
	if (cur == nth)
		return list;

	if (cur < nth)
		while ((cur++ < nth) && list)
			list = list->next;
	else if (cur > nth)
		while ((cur-- > nth) && list)
			list = list->prev;

	return list;
}


The second speed hack is so simple I'm actually scared about the
significance. I simply replaced one g_list_append with g_list_prepend in
tny-msg-folder.c. And now loading huge folders happens very fast.


Enjoy the speed.


-- 
Philip Van Hoof, software developer at x-tend 
home: me at pvanhoof dot be 
gnome: pvanhoof at gnome dot org 
work: vanhoof at x-tend dot be 
http://www.pvanhoof.be - http://www.x-tend.be




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]