pidgin.next.minor: 55e24044: Add constant-time lookup of row in the u...
darkrain42 at pidgin.im
darkrain42 at pidgin.im
Tue Jun 21 00:52:40 EDT 2011
----------------------------------------------------------------------
Revision: 55e24044dabdcaa882f1745291777d602846e2c1
Parent: f4d5c0f55ddcacbb71b8fb16642cb0fd7344903f
Author: darkrain42 at pidgin.im
Date: 06/21/11 00:35:04
Branch: im.pidgin.pidgin.next.minor
URL: http://d.pidgin.im/viewmtn/revision/info/55e24044dabdcaa882f1745291777d602846e2c1
Changelog:
Add constant-time lookup of row in the userlist by way of PurpleConvChatBuddy ui_data
Thanks to elb for pointing out GtkTreeRowReference.
Unfortunately, pidgin_conv_chat_remove_users cannot benefit from this because
the PCCB struct is destroyed prior to the uiop being called.
Joining #pidgin and #ubuntu is now extremely quick.
Changes against parent f4d5c0f55ddcacbb71b8fb16642cb0fd7344903f
patched ChangeLog
patched ChangeLog.API
patched libpurple/conversation.c
patched libpurple/value.h
patched pidgin/gtkconv.c
-------------- next part --------------
============================================================
--- ChangeLog 157f251bf1e82e31628b4fd1228929b8d3fa08fc
+++ ChangeLog 81f95a2f4ce8f8968994ee5266c65196aef1343f
@@ -1,6 +1,9 @@ version 2.9.0 (MM/DD/YYYY):
Pidgin and Finch: The Pimpin' Penguin IM Clients That're Good for the Soul
version 2.9.0 (MM/DD/YYYY):
+ Pidgin:
+ * Significantly improved performance of larger IRC channels (regression
+ introduced in 2.8.0)
version 2.8.1 (MM/DD/YYYY):
Pidgin:
============================================================
--- libpurple/conversation.c 42560dbf96f8031925d95450e459ed38246a98b1
+++ libpurple/conversation.c cac6ff769a906ace740507924440fe1c882b83b3
@@ -2185,6 +2185,9 @@ purple_conv_chat_cb_destroy(PurpleConvCh
if (cb == NULL)
return;
+ purple_signal_emit(purple_conversations_get_handle(),
+ "deleting-chat-buddy", cb);
+
g_free(cb->alias);
g_free(cb->alias_key);
g_free(cb->name);
@@ -2591,6 +2594,11 @@ purple_conversations_init(void)
purple_value_new(PURPLE_TYPE_STRING),
purple_value_new(PURPLE_TYPE_STRING));
+ purple_signal_register(handle, "deleting-chat-buddy",
+ purple_marshal_VOID__POINTER, NULL, 1,
+ purple_value_new(PURPLE_TYPE_SUBTYPE,
+ PURPLE_SUBTYPE_CHATBUDDY));
+
purple_signal_register(handle, "chat-inviting-user",
purple_marshal_VOID__POINTER_POINTER_POINTER, NULL, 3,
purple_value_new(PURPLE_TYPE_SUBTYPE,
============================================================
--- pidgin/gtkconv.c 747ecb0a2d6ea8818839b6bc8781d74d54c0c160
+++ pidgin/gtkconv.c 0114a0622f481e1fd762afc74de12fe239a90f1a
@@ -3978,6 +3978,16 @@ static void
}
static void
+deleting_chat_buddy_cb(PurpleConvChatBuddy *cb)
+{
+ if (cb->ui_data) {
+ GtkTreeRowReference *ref = cb->ui_data;
+ gtk_tree_row_reference_free(ref);
+ cb->ui_data = NULL;
+ }
+}
+
+static void
add_chat_buddy_common(PurpleConversation *conv, PurpleConvChatBuddy *cb, const char *old_name)
{
PidginConversation *gtkconv;
@@ -3985,7 +3995,9 @@ add_chat_buddy_common(PurpleConversation
PurpleConvChat *chat;
PurpleConnection *gc;
PurplePluginProtocolInfo *prpl_info;
+ GtkTreeModel *tm;
GtkListStore *ls;
+ GtkTreePath *newpath;
const char *stock;
GtkTreeIter iter;
gboolean is_me = FALSE;
@@ -4006,7 +4018,8 @@ add_chat_buddy_common(PurpleConversation
if (!gc || !(prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)))
return;
- ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)));
+ tm = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list));
+ ls = GTK_LIST_STORE(tm);
stock = get_chat_buddy_status_icon(chat, name, flags);
@@ -4051,6 +4064,15 @@ add_chat_buddy_common(PurpleConversation
CHAT_USERS_WEIGHT_COLUMN, is_buddy ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL,
-1);
+ if (cb->ui_data) {
+ GtkTreeRowReference *ref = cb->ui_data;
+ gtk_tree_row_reference_free(ref);
+ }
+
+ newpath = gtk_tree_model_get_path(tm, &iter);
+ cb->ui_data = gtk_tree_row_reference_new(tm, newpath);
+ gtk_tree_path_free(newpath);
+
if (is_me && color)
gdk_color_free(color);
g_free(alias_key);
@@ -6102,6 +6124,28 @@ pidgin_conv_write_conv(PurpleConversatio
update_typing_message(gtkconv, NULL);
}
+static gboolean get_iter_from_chatbuddy(PurpleConvChatBuddy *cb, GtkTreeIter *iter)
+{
+ GtkTreeRowReference *ref = cb->ui_data;
+ GtkTreePath *path;
+ GtkTreeModel *model;
+
+ if (!ref)
+ return FALSE;
+
+ if ((path = gtk_tree_row_reference_get_path(ref)) == NULL)
+ return FALSE;
+
+ model = gtk_tree_row_reference_get_model(ref);
+ if (!gtk_tree_model_get_iter(GTK_TREE_MODEL(model), iter, path)) {
+ gtk_tree_path_free(path);
+ return FALSE;
+ }
+
+ gtk_tree_path_free(path);
+ return TRUE;
+}
+
static void
pidgin_conv_chat_add_users(PurpleConversation *conv, GList *cbuddies, gboolean new_arrivals)
{
@@ -6152,12 +6196,10 @@ pidgin_conv_chat_rename_user(PurpleConve
PurpleConvChat *chat;
PidginConversation *gtkconv;
PidginChatPane *gtkchat;
- PurpleConvChatBuddyFlags flags;
- PurpleConvChatBuddy *cbuddy;
+ PurpleConvChatBuddy *old_cbuddy, *new_cbuddy;
GtkTreeIter iter;
GtkTreeModel *model;
GtkTextTag *tag;
- int f = 1;
chat = PURPLE_CONV_CHAT(conv);
gtkconv = PIDGIN_CONVERSATION(conv);
@@ -6168,20 +6210,13 @@ pidgin_conv_chat_rename_user(PurpleConve
if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter))
return;
- while (f != 0) {
- char *val;
+ old_cbuddy = purple_conv_chat_cb_find(chat, old_name);
+ if (get_iter_from_chatbuddy(old_cbuddy, &iter)) {
+ GtkTreeRowReference *ref = old_cbuddy->ui_data;
- gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, CHAT_USERS_FLAGS_COLUMN, &flags, -1);
-
- if (!purple_utf8_strcasecmp(old_name, val)) {
- gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
- g_free(val);
- break;
- }
-
- f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter);
-
- g_free(val);
+ gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
+ gtk_tree_row_reference_free(ref);
+ old_cbuddy->ui_data = NULL;
}
if ((tag = get_buddy_tag(conv, old_name, 0, FALSE)))
@@ -6189,14 +6224,14 @@ pidgin_conv_chat_rename_user(PurpleConve
if ((tag = get_buddy_tag(conv, old_name, PURPLE_MESSAGE_NICK, FALSE)))
g_object_set(G_OBJECT(tag), "style", PANGO_STYLE_ITALIC, NULL);
- if (!purple_conv_chat_find_user(chat, old_name))
+ if (!old_cbuddy)
return;
g_return_if_fail(new_alias != NULL);
- cbuddy = purple_conv_chat_cb_find(chat, new_name);
+ new_cbuddy = purple_conv_chat_cb_find(chat, new_name);
- add_chat_buddy_common(conv, cbuddy, old_name);
+ add_chat_buddy_common(conv, new_cbuddy, old_name);
}
static void
@@ -6223,6 +6258,7 @@ pidgin_conv_chat_remove_users(PurpleConv
model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list));
if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter))
+ /* XXX: Break? */
continue;
do {
@@ -6262,8 +6298,6 @@ pidgin_conv_chat_update_user(PurpleConve
PidginChatPane *gtkchat;
GtkTreeIter iter;
GtkTreeModel *model;
- int f = 1;
- char *alias = NULL;
chat = PURPLE_CONV_CHAT(conv);
gtkconv = PIDGIN_CONVERSATION(conv);
@@ -6274,29 +6308,16 @@ pidgin_conv_chat_update_user(PurpleConve
if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter))
return;
- while (f != 0) {
- char *val;
-
- gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1);
-
- if (!purple_utf8_strcasecmp(user, val)) {
- gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_ALIAS_COLUMN, &alias, -1);
- gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
- g_free(val);
- break;
- }
-
- f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter);
-
- g_free(val);
+ cbuddy = purple_conv_chat_cb_find(chat, user);
+ if (get_iter_from_chatbuddy(cbuddy, &iter)) {
+ GtkTreeRowReference *ref = cbuddy->ui_data;
+ gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
+ gtk_tree_row_reference_free(ref);
+ cbuddy->ui_data = NULL;
}
- g_return_if_fail(alias != NULL);
-
- cbuddy = purple_conv_chat_cb_find(chat, user);
if (cbuddy)
add_chat_buddy_common(conv, cbuddy, NULL);
- g_free(alias);
}
gboolean
@@ -8077,6 +8098,9 @@ pidgin_conversations_init(void)
purple_signal_connect(purple_conversations_get_handle(), "cleared-message-history",
handle, G_CALLBACK(clear_conversation_scrollback_cb), NULL);
+ purple_signal_connect(purple_conversations_get_handle(), "deleting-chat-buddy",
+ handle, G_CALLBACK(deleting_chat_buddy_cb), NULL);
+
purple_conversations_set_ui_ops(&conversation_ui_ops);
hidden_convwin = pidgin_conv_window_new();
============================================================
--- libpurple/value.h 3a7b6a6dd8106466d5a438203706c2bc0c2b6cd9
+++ libpurple/value.h 2e4ee485ddf46affd4170adf8e560b17024fdbba
@@ -79,7 +79,8 @@ typedef enum
PURPLE_SUBTYPE_XMLNODE,
PURPLE_SUBTYPE_USERINFO,
PURPLE_SUBTYPE_STORED_IMAGE,
- PURPLE_SUBTYPE_CERTIFICATEPOOL
+ PURPLE_SUBTYPE_CERTIFICATEPOOL,
+ PURPLE_SUBTYPE_CHATBUDDY
} PurpleSubType;
/**
============================================================
--- ChangeLog.API 04300204f2516924d7cfd9e165b37153c4d67834
+++ ChangeLog.API 1428741f6d66d8bb823e2c457498fdffbd4c8406
@@ -5,7 +5,8 @@ version 2.9.0 (MM/DD/YYYY):
Added:
* Hash table to PurpleConvChat struct, used to make
purple_conv_chat_cb_find O(1).
- * ui_data opaque pointer to PurpleConvChatBuddy struct.
+ * ui_data pointer to PurpleConvChatBuddy struct.
+ * deleting-chat-buddy signal (conversation signals)
Deprecated:
* purple_conv_chat_set_users
More information about the Commits
mailing list