comparison libpurple/account.c @ 23963:d1797f30960f

An optimization for purple_accounts_find() to eliminate a malloc/free per iteration from Florian Queze. Fixes #6194.
author Daniel Atallah <daniel.atallah@gmail.com>
date Sun, 31 Aug 2008 17:54:21 +0000
parents 7097bbac4234
children 8282911d5e17
comparison
equal deleted inserted replaced
23962:78c64f7c598f 23963:d1797f30960f
2612 2612
2613 g_return_val_if_fail(name != NULL, NULL); 2613 g_return_val_if_fail(name != NULL, NULL);
2614 2614
2615 for (l = purple_accounts_get_all(); l != NULL; l = l->next) { 2615 for (l = purple_accounts_get_all(); l != NULL; l = l->next) {
2616 account = (PurpleAccount *)l->data; 2616 account = (PurpleAccount *)l->data;
2617 if (protocol_id && strcmp(account->protocol_id, protocol_id))
2618 continue;
2617 2619
2618 who = g_strdup(purple_normalize(account, name)); 2620 who = g_strdup(purple_normalize(account, name));
2619 if (!strcmp(purple_normalize(account, purple_account_get_username(account)), who) && 2621 if (!strcmp(purple_normalize(account, purple_account_get_username(account)), who)) {
2620 (!protocol_id || !strcmp(account->protocol_id, protocol_id))) {
2621 g_free(who); 2622 g_free(who);
2622 break; 2623 return account;
2623 } 2624 }
2624 g_free(who); 2625 g_free(who);
2625 account = NULL; 2626 }
2626 } 2627
2627 2628 return NULL;
2628 return account;
2629 } 2629 }
2630 2630
2631 void 2631 void
2632 purple_accounts_restore_current_statuses() 2632 purple_accounts_restore_current_statuses()
2633 { 2633 {