From 22e9f72a8e23c9469c2891e48e082be664429dac Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 23 Jun 2012 17:30:10 -0400 Subject: [PATCH] Add a note of caution to the g_slist_delete_link() docs --- glib/gslist.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/glib/gslist.c b/glib/gslist.c index 8d32d05e2..1b047ec4a 100644 --- a/glib/gslist.c +++ b/glib/gslist.c @@ -515,6 +515,12 @@ _g_slist_remove_link (GSList *list, * link is set to %NULL, so that it becomes a * self-contained list with one element. * + * Removing arbitrary nodes from a singly-linked list + * requires time that is proportional to the length of the list + * (ie. O(n)). If you find yourself using g_slist_remove_link() + * frequently, you should consider a different data structure, such + * as the doubly-linked #GList. + * * Returns: the new start of the #GSList, without the element */ GSList* @@ -533,6 +539,12 @@ g_slist_remove_link (GSList *list, * Compare this to g_slist_remove_link() which removes the node * without freeing it. * + * Removing arbitrary nodes from a singly-linked list + * requires time that is proportional to the length of the list + * (ie. O(n)). If you find yourself using g_slist_delete_link() + * frequently, you should consider a different data structure, such + * as the doubly-linked #GList. + * * Returns: the new head of @list */ GSList*