diff pidgin/plugins/musicmessaging/musicmessaging.c @ 15786:e926951e61fe

Don't use g_list_length() and g_slist_length() when all you want to do if check if the list is empty. Those two functions needlessly iterate through the entire list.
author Mark Doliner <mark@kingant.net>
date Tue, 13 Mar 2007 07:19:06 +0000
parents 535f002e7b0f
children 32c366eeeb99
line wrap: on
line diff
--- a/pidgin/plugins/musicmessaging/musicmessaging.c	Tue Mar 13 06:53:43 2007 +0000
+++ b/pidgin/plugins/musicmessaging/musicmessaging.c	Tue Mar 13 07:19:06 2007 +0000
@@ -235,16 +235,19 @@
 static int
 mmconv_from_conv_loc(GaimConversation *conv)
 {
+	GList *l;
 	MMConversation *mmconv_current = NULL;
 	guint i;
 	
-	for (i = 0; i < g_list_length(conversations); i++)
+	i = 0;
+	for (l = conversations; l != NULL; l = l->next)
 	{
-		mmconv_current = (MMConversation *)g_list_nth_data(conversations, i);
+		mmconv_current = l->data;
 		if (conv == mmconv_current->conv)
 		{
 			return i;
 		}
+		i++;
 	}
 	return -1;
 }
@@ -295,9 +298,9 @@
 plugin_unload(GaimPlugin *plugin) {
 	MMConversation *mmconv = NULL;
 	
-	while (g_list_length(conversations) > 0)
+	while (conversations != NULL)
 	{
-		mmconv = g_list_first(conversations)->data;
+		mmconv = conversations->data;
 		conv_destroyed(mmconv->conv);
 	}
 	return TRUE;