summaryrefslogtreecommitdiff
path: root/gslist.c
diff options
context:
space:
mode:
authorTim Janik <timj@gtk.org>2000-03-01 09:44:10 +0000
committerTim Janik <timj@src.gnome.org>2000-03-01 09:44:10 +0000
commitdb8baf697889c80c0632d7cc91343c18a2647429 (patch)
tree0c33983550e73a88b4aa2d7f09bc905cf3e4c0b5 /gslist.c
parentd568a76ae4976e0aa01e26e868121a07b4e91338 (diff)
downloadglib-db8baf697889c80c0632d7cc91343c18a2647429.tar.gz
minor optimization.
Wed Mar 1 10:39:39 2000 Tim Janik <timj@gtk.org> * gslist.c (g_slist_reverse): minor optimization. * testglib.c (g_node_test): added a couple of tests for g_node_copy(). * glib.h: * gnode.c (g_node_copy): new function to copy subtrees, supplied by dbsears@ix.netcom.com. changed iterator to walk the children list backwards, so we get down from O(n^2) to O(n). * gnode.c (g_node_first_sibling): applied patch from dbsears@ix.netcom.com to optimize access if node->parent is present. * gutils.c (g_get_any_init): backed out HAVE_PW_GECOS check around assignment of g_real_name, sicne HAVE_PW_GECOS is never defined and thus breaks the original code. * merged changes from 1.2.7. Sat Feb 19 19:43:29 2000 Tim Janik <timj@gtk.org> * testgmodule.c (main): added test to check that not yet bound symbols in shared libraries of the main module are retrievable, from David Gero. Fri Jan 28 11:37:41 2000 Owen Taylor <otaylor@redhat.com> Bug #4156 - Changes vaguely modelled after Scott Gifford's patch * gtimer.c (g_timer_elapsed): Never report negative times - clip times to 0. * gmain.c (g_timeout_prepare): Guard against unexpected clock shifts by never setting a timeout of more than data->interval msecs.
Diffstat (limited to 'gslist.c')
-rw-r--r--gslist.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/gslist.c b/gslist.c
index 9e7c88f34..2f01673b0 100644
--- a/gslist.c
+++ b/gslist.c
@@ -377,32 +377,26 @@ g_slist_copy (GSList *list)
GSList*
g_slist_reverse (GSList *list)
{
- GSList *tmp;
- GSList *prev;
- GSList *last;
-
- last = NULL;
- prev = NULL;
-
+ GSList *prev = NULL;
+ GSList *next = NULL;
+
while (list)
{
- last = list;
-
- tmp = list->next;
+ next = list->next;
list->next = prev;
-
+
prev = list;
- list = tmp;
+ list = next;
}
-
- return last;
+
+ return prev;
}
GSList*
g_slist_nth (GSList *list,
guint n)
{
- while ((n-- > 0) && list)
+ while (n-- > 0 && list)
list = list->next;
return list;
@@ -412,7 +406,7 @@ gpointer
g_slist_nth_data (GSList *list,
guint n)
{
- while ((n-- > 0) && list)
+ while (n-- > 0 && list)
list = list->next;
return list ? list->data : NULL;