pidgin: 2e77aeea: An optimization for purple_accounts_find...

datallah at pidgin.im datallah at pidgin.im
Sun Aug 31 13:55:37 EDT 2008


-----------------------------------------------------------------
Revision: 2e77aeeae64a3dc7d0d07ed8fb675c0d2363de55
Ancestor: 3fa7c8d605ac64dc7cd1384f7de02c39bd0eb840
Author: datallah at pidgin.im
Date: 2008-08-31T17:54:21
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/2e77aeeae64a3dc7d0d07ed8fb675c0d2363de55

Modified files:
        COPYRIGHT libpurple/account.c

ChangeLog: 

An optimization for purple_accounts_find() to eliminate a malloc/free per
iteration from Florian Queze. Fixes #6194.

-------------- next part --------------
============================================================
--- COPYRIGHT	586ae7f517e5b9ab70a150e2281e0a471723b974
+++ COPYRIGHT	72c5af1656198314390a81ad0a27acd2d9dab269
@@ -320,6 +320,7 @@ Justin Pryzby
 Jory A. Pratt
 Brent Priddy
 Justin Pryzby
+Florian Quèze
 Ignacio Casal Quinteiro
 Federicco Mena Quintero
 Yosef Radchenko
============================================================
--- libpurple/account.c	c868e8cb151bd6f346ea4e9826733ab64680188c
+++ libpurple/account.c	247775131c335af3e7aa0ab787867b5b51b4d4f9
@@ -2614,18 +2614,18 @@ purple_accounts_find(const char *name, c
 
 	for (l = purple_accounts_get_all(); l != NULL; l = l->next) {
 		account = (PurpleAccount *)l->data;
+		if (protocol_id && strcmp(account->protocol_id, protocol_id))
+		  continue;
 
 		who = g_strdup(purple_normalize(account, name));
-		if (!strcmp(purple_normalize(account, purple_account_get_username(account)), who) &&
-			(!protocol_id || !strcmp(account->protocol_id, protocol_id))) {
+		if (!strcmp(purple_normalize(account, purple_account_get_username(account)), who)) {
 			g_free(who);
-			break;
+			return account;
 		}
 		g_free(who);
-		account = NULL;
 	}
 
-	return account;
+	return NULL;
 }
 
 void


More information about the Commits mailing list