cpw.darkrain42.irc: 2e25c348: Plucked Zac's collate key for PCCB (and ...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Mon Jul 13 00:15:57 EDT 2009


-----------------------------------------------------------------
Revision: 2e25c348bd47a4b879b2933a6fff9c3b373ee1aa
Ancestor: f617a272019432dcb4537f2d2b42fd3ea9ec54e2
Author: darkrain42 at pidgin.im
Date: 2009-07-12T23:04:50
Branch: im.pidgin.cpw.darkrain42.irc
URL: http://d.pidgin.im/viewmtn/revision/info/2e25c348bd47a4b879b2933a6fff9c3b373ee1aa

Modified files:
        libpurple/conversation.c libpurple/conversation.h

ChangeLog: 

Plucked Zac's collate key for PCCB (and moved to end of struct)

*** Plucked rev ec7b74f84bcc99f27c6008c48cf322aaf0a7e12e (zacw at adiumx.com):
Add a collate key to PurpleConvChatBuddy, and use the key when searching for a specific buddy. This is a *significant* speed increase when searching for a lot of buddies.


-------------- next part --------------
============================================================
--- libpurple/conversation.c	ac715edc2f1fcba1a2531105bed9611fbcb6334d
+++ libpurple/conversation.c	dd2bb68ad7946dd44085df8b53be4f19d4f40fa8
@@ -2081,6 +2081,7 @@ purple_conv_chat_cb_new(const char *name
 
 	cb = g_new0(PurpleConvChatBuddy, 1);
 	cb->name = g_strdup(name);
+	cb->collate_key = g_utf8_collate_key(name, -1);
 	cb->flags = flags;
 	cb->alias = g_strdup(alias);
 	cb->attributes = g_hash_table_new_full(g_str_hash, g_str_equal,
@@ -2095,15 +2096,22 @@ purple_conv_chat_cb_find(PurpleConvChat 
 {
 	GList *l;
 	PurpleConvChatBuddy *cb = NULL;
+	char *collate_key;
 
 	g_return_val_if_fail(chat != NULL, NULL);
 	g_return_val_if_fail(name != NULL, NULL);
+	
+	collate_key = g_utf8_collate_key(name, -1);
 
 	for (l = purple_conv_chat_get_users(chat); l; l = l->next) {
 		cb = l->data;
-		if (!g_utf8_collate(cb->name, name))
+		if (purple_strequal(cb->collate_key, collate_key)) {
+			g_free(collate_key);
 			return cb;
+		}
 	}
+	
+	g_free(collate_key);
 
 	return NULL;
 }
@@ -2117,6 +2125,7 @@ purple_conv_chat_cb_destroy(PurpleConvCh
 	g_free(cb->alias);
 	g_free(cb->alias_key);
 	g_free(cb->name);
+	g_free(cb->collate_key);
 	g_hash_table_destroy(cb->attributes);
 
 	PURPLE_DBUS_UNREGISTER_POINTER(cb);
============================================================
--- libpurple/conversation.h	16fa562c38d57c0eee0450aa348885bdceb8070e
+++ libpurple/conversation.h	0dedc4fa74d97c8b8ef8b7bb61d72593355542bb
@@ -304,6 +304,7 @@ struct _PurpleConvChatBuddy
 	                                  *   such as real name, user at host, etc.
 	                                  *   @since 2.6.0.
 	                                  */
+	char *collate_key;				 /**< A string by which this buddy can be compared with other collate keys. */
 };
 
 /**


More information about the Commits mailing list