# HG changeset patch # User Mark Doliner # Date 1173770346 0 # Node ID e926951e61fe02e747fd993fa9ad7f8029f5e06f # Parent eed84b59c252f550cc9be95c7ff2e02dd53d9d66 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. diff -r eed84b59c252 -r e926951e61fe libpurple/protocols/jabber/roster.c --- a/libpurple/protocols/jabber/roster.c Tue Mar 13 06:53:43 2007 +0000 +++ b/libpurple/protocols/jabber/roster.c Tue Mar 13 07:19:06 2007 +0000 @@ -380,7 +380,7 @@ GSList *groups = NULL; buddies = g_slist_remove(buddies, buddy); - if(g_slist_length(buddies)) { + if(buddies != NULL) { GaimBuddy *tmpbuddy; GaimGroup *tmpgroup; diff -r eed84b59c252 -r e926951e61fe libpurple/protocols/jabber/si.c --- a/libpurple/protocols/jabber/si.c Tue Mar 13 06:53:43 2007 +0000 +++ b/libpurple/protocols/jabber/si.c Tue Mar 13 07:19:06 2007 +0000 @@ -783,7 +783,7 @@ return; /* XXX: for now, send to the first resource available */ - if(g_list_length(jb->resources) >= 1) { + if(jb->resources != NULL) { char **who_v = g_strsplit(xfer->who, "/", 2); char *who; diff -r eed84b59c252 -r e926951e61fe libpurple/protocols/novell/nmuser.c --- a/libpurple/protocols/novell/nmuser.c Tue Mar 13 06:53:43 2007 +0000 +++ b/libpurple/protocols/novell/nmuser.c Tue Mar 13 07:19:06 2007 +0000 @@ -1534,13 +1534,12 @@ } /* Time to callback? */ - if (g_slist_length(list) == 0) { + if (list == NULL) { nm_response_cb cb = nm_request_get_callback(request); if (cb) { cb(user, 0, conference, conference); } - g_slist_free(list); nm_release_request(request); } } diff -r eed84b59c252 -r e926951e61fe pidgin/gtkimhtmltoolbar.c --- a/pidgin/gtkimhtmltoolbar.c Tue Mar 13 06:53:43 2007 +0000 +++ b/pidgin/gtkimhtmltoolbar.c Tue Mar 13 07:19:06 2007 +0000 @@ -672,7 +672,7 @@ gtk_window_set_role(GTK_WINDOW(dialog), "smiley_dialog"); gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE); - if (g_slist_length(unique_smileys)) { + if (unique_smileys != NULL) { struct smiley_button_list *ls, *it, *it_tmp; GtkWidget *line; int line_width = 0; diff -r eed84b59c252 -r e926951e61fe pidgin/plugins/musicmessaging/musicmessaging.c --- 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;