comparison 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
comparison
equal deleted inserted replaced
15785:eed84b59c252 15786:e926951e61fe
233 233
234 234
235 static int 235 static int
236 mmconv_from_conv_loc(GaimConversation *conv) 236 mmconv_from_conv_loc(GaimConversation *conv)
237 { 237 {
238 GList *l;
238 MMConversation *mmconv_current = NULL; 239 MMConversation *mmconv_current = NULL;
239 guint i; 240 guint i;
240 241
241 for (i = 0; i < g_list_length(conversations); i++) 242 i = 0;
242 { 243 for (l = conversations; l != NULL; l = l->next)
243 mmconv_current = (MMConversation *)g_list_nth_data(conversations, i); 244 {
245 mmconv_current = l->data;
244 if (conv == mmconv_current->conv) 246 if (conv == mmconv_current->conv)
245 { 247 {
246 return i; 248 return i;
247 } 249 }
250 i++;
248 } 251 }
249 return -1; 252 return -1;
250 } 253 }
251 254
252 static MMConversation* 255 static MMConversation*
293 296
294 static gboolean 297 static gboolean
295 plugin_unload(GaimPlugin *plugin) { 298 plugin_unload(GaimPlugin *plugin) {
296 MMConversation *mmconv = NULL; 299 MMConversation *mmconv = NULL;
297 300
298 while (g_list_length(conversations) > 0) 301 while (conversations != NULL)
299 { 302 {
300 mmconv = g_list_first(conversations)->data; 303 mmconv = conversations->data;
301 conv_destroyed(mmconv->conv); 304 conv_destroyed(mmconv->conv);
302 } 305 }
303 return TRUE; 306 return TRUE;
304 } 307 }
305 308