From: <aar...@us...> - 2006-07-04 23:46:06
|
Revision: 16429 Author: aaronsheldon Date: 2006-07-04 16:45:59 -0700 (Tue, 04 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16429&view=rev Log Message: ----------- Mass code cleanup. Should be good enough to use now. Dramatic speedups in large room joins. Modified Paths: -------------- branches/soc-2006-chat-speed/src/conversation.c branches/soc-2006-chat-speed/src/conversation.h branches/soc-2006-chat-speed/src/gtkconv.c Modified: branches/soc-2006-chat-speed/src/conversation.c =================================================================== --- branches/soc-2006-chat-speed/src/conversation.c 2006-07-04 23:15:43 UTC (rev 16428) +++ branches/soc-2006-chat-speed/src/conversation.c 2006-07-04 23:45:59 UTC (rev 16429) @@ -39,8 +39,6 @@ static GaimConversationUiOps *default_ops = NULL; int gaim_conv_chat_cb_compare(GaimConvChatBuddy *a, GaimConvChatBuddy *b); -GaimConvChatBuddy *gaim_conv_chat_cb_new2(const char *name, const char *alias, - GaimConvChatBuddyFlags flags); void gaim_conversations_set_ui_ops(GaimConversationUiOps *ops) @@ -1480,8 +1478,8 @@ GaimConvChatBuddyFlags flags = GPOINTER_TO_INT(fl->data); const char *extra_msg = (extra_msgs ? extra_msgs->data : NULL); - cbuddy = gaim_conv_chat_cb_new(user, GPOINTER_TO_INT(fl->data)); - + cbuddy = gaim_conv_chat_cb_new(user, NULL, GPOINTER_TO_INT(fl->data)); + if (!strcmp(chat->nick, gaim_normalize(conv->account, user))) { const char *alias2 = gaim_account_get_alias(conv->account); if (alias2 != NULL) @@ -1502,7 +1500,7 @@ "chat-buddy-joining", conv, user, flags)) | gaim_conv_chat_is_user_ignored(chat, user); - cb = gaim_conv_chat_cb_new(user, flags); + cb = gaim_conv_chat_cb_new(user, NULL, flags); /* This seems dumb. Why should we set users thousands of times? */ gaim_conv_chat_set_users(chat, g_list_prepend(gaim_conv_chat_get_users(chat), cb)); @@ -1540,13 +1538,13 @@ cbuddies = g_list_sort(cbuddies, (GCompareFunc)gaim_conv_chat_cb_compare); - if (ops != NULL && ops->chat_add_users2 != NULL) - ops->chat_add_users2(conv, cbuddies, new_arrivals); - + if (ops != NULL && ops->chat_add_users != NULL) + ops->chat_add_users(conv, cbuddies, new_arrivals); + } - -int gaim_conv_chat_cb_compare(GaimConvChatBuddy *a, GaimConvChatBuddy *b) +int +gaim_conv_chat_cb_compare(GaimConvChatBuddy *a, GaimConvChatBuddy *b) { GaimConvChatBuddyFlags f1 = 0, f2 = 0; char *user1 = NULL, *user2 = NULL; @@ -1569,18 +1567,6 @@ user2 = b->name; } - /* - gtk_tree_model_get(model, a, - CHAT_USERS_ALIAS_KEY_COLUMN, &user1, - CHAT_USERS_FLAGS_COLUMN, &f1, - CHAT_USERS_BUDDY_COLUMN, &buddy1, - -1); - gtk_tree_model_get(model, b, - CHAT_USERS_ALIAS_KEY_COLUMN, &user2, - CHAT_USERS_FLAGS_COLUMN, &f2, - CHAT_USERS_BUDDY_COLUMN, &buddy2, - -1);*/ - if (user1 == NULL || user2 == NULL) { if (!(user1 == NULL && user2 == NULL)) ret = (user1 == NULL) ? -1: 1; @@ -1625,7 +1611,7 @@ flags = gaim_conv_chat_user_get_flags(chat, old_user); /* Check this later - F.P. */ - cb = gaim_conv_chat_cb_new(new_user, flags); + cb = gaim_conv_chat_cb_new(new_user, NULL, flags); gaim_conv_chat_set_users(chat, g_list_prepend(gaim_conv_chat_get_users(chat), cb)); @@ -1936,9 +1922,8 @@ return chat->left; } - GaimConvChatBuddy * -gaim_conv_chat_cb_new(const char *name, GaimConvChatBuddyFlags flags) +gaim_conv_chat_cb_new(const char *name, const char *alias, GaimConvChatBuddyFlags flags) { GaimConvChatBuddy *cb; @@ -1947,26 +1932,10 @@ cb = g_new0(GaimConvChatBuddy, 1); cb->name = g_strdup(name); cb->flags = flags; - cb->alias = g_strdup(name); - - GAIM_DBUS_REGISTER_POINTER(cb, GaimConvChatBuddy); - return cb; -} - -GaimConvChatBuddy * -gaim_conv_chat_cb_new2(const char *name, const char *alias, GaimConvChatBuddyFlags flags) -{ - GaimConvChatBuddy *cb; - - g_return_val_if_fail(name != NULL, NULL); - - cb = g_new0(GaimConvChatBuddy, 1); - cb->name = g_strdup(name); - cb->flags = flags; if (alias) cb->alias = g_strdup(alias); else - cb->alias = g_strdup(name); + cb->alias = NULL; GAIM_DBUS_REGISTER_POINTER(cb, GaimConvChatBuddy); return cb; Modified: branches/soc-2006-chat-speed/src/conversation.h =================================================================== --- branches/soc-2006-chat-speed/src/conversation.h 2006-07-04 23:15:43 UTC (rev 16428) +++ branches/soc-2006-chat-speed/src/conversation.h 2006-07-04 23:45:59 UTC (rev 16429) @@ -158,11 +158,8 @@ const char *message, GaimMessageFlags flags, time_t mtime); - void (*chat_add_users)(GaimConversation *conv, GList *users, - GList *flags, GList *aliases, gboolean new_arrivals); + void (*chat_add_users)(GaimConversation *conv, GList *cbuddies, gboolean new_arrivals); - void (*chat_add_users2)(GaimConversation *conv, GList *cbuddies, gboolean new_arrivals); - void (*chat_rename_user)(GaimConversation *conv, const char *old_name, const char *new_name, const char *new_alias); void (*chat_remove_users)(GaimConversation *conv, GList *users); @@ -1019,6 +1016,7 @@ */ void gaim_conv_chat_add_users(GaimConvChat *chat, GList *users, GList *extra_msgs, GList *flags, gboolean new_arrivals); + /** * Renames a user in a chat. @@ -1139,23 +1137,12 @@ * Creates a new chat buddy * * @param name The name. - * @param flags The flags. - * - * @return The new chat buddy - */ -GaimConvChatBuddy *gaim_conv_chat_cb_new(const char *name, - GaimConvChatBuddyFlags flags); - -/** - * Creates a new chat buddy - * - * @param name The name. * @param alias The alias. * @param flags The flags. * * @return The new chat buddy */ -GaimConvChatBuddy *gaim_conv_chat_cb_new2(const char *name, const char *alias, +GaimConvChatBuddy *gaim_conv_chat_cb_new(const char *name, const char *alias, GaimConvChatBuddyFlags flags); /** Modified: branches/soc-2006-chat-speed/src/gtkconv.c =================================================================== --- branches/soc-2006-chat-speed/src/gtkconv.c 2006-07-04 23:15:43 UTC (rev 16428) +++ branches/soc-2006-chat-speed/src/gtkconv.c 2006-07-04 23:45:59 UTC (rev 16429) @@ -1424,7 +1424,7 @@ else gaim_conv_chat_ignore(chat, name); - cbuddy = gaim_conv_chat_cb_new2(name, alias, flags); + cbuddy = gaim_conv_chat_cb_new(name, alias, flags); add_chat_buddy_common(conv, cbuddy, NULL); g_free(name); @@ -5023,62 +5023,15 @@ account, name, message, conv, flags); g_free(displaying); } -/* This function is deprecated and I will replace it with the version below soon. */ static void -gaim_gtkconv_chat_add_users(GaimConversation *conv, GList *users, GList *flags, GList *aliases, gboolean new_arrivals) +gaim_gtkconv_chat_add_users(GaimConversation *conv, GList *cbuddies, gboolean new_arrivals) { GaimConvChat *chat; GaimGtkConversation *gtkconv; GaimGtkChatPane *gtkchat; GtkListStore *ls; GList *l; - GList *ll; - GList *lll; - char tmp[BUF_LONG]; - int num_users; - chat = GAIM_CONV_CHAT(conv); - gtkconv = GAIM_GTK_CONVERSATION(conv); - gtkchat = gtkconv->u.chat; - - num_users = g_list_length(gaim_conv_chat_get_users(chat)); - - g_snprintf(tmp, sizeof(tmp), - ngettext("%d person in room", "%d people in room", - num_users), - num_users); - - gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); - - ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); - gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, - GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID); - - l = users; - ll = flags; - lll = aliases; - while (l != NULL && ll != NULL && lll != NULL) { - GaimConvChatBuddy *cb = gaim_conv_chat_cb_new2((const char*)l->data, (const char *)lll->data, GPOINTER_TO_INT(ll->data)); - add_chat_buddy_common(conv, cb, NULL); - l = l->next; - ll = ll->next; - lll = lll->next; - } - - gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_KEY_COLUMN, - GTK_SORT_ASCENDING); - -} - -static void -gaim_gtkconv_chat_add_users2(GaimConversation *conv, GList *cbuddies, gboolean new_arrivals) -{ - GaimConvChat *chat; - GaimGtkConversation *gtkconv; - GaimGtkChatPane *gtkchat; - GtkListStore *ls; - GList *l; - char tmp[BUF_LONG]; int num_users; @@ -5159,7 +5112,7 @@ g_return_if_fail(new_alias != NULL); - cbuddy = gaim_conv_chat_cb_new2(new_name, new_alias, flags); + cbuddy = gaim_conv_chat_cb_new(new_name, new_alias, flags); add_chat_buddy_common(conv, cbuddy, old_name); } @@ -5266,7 +5219,7 @@ flags = gaim_conv_chat_user_get_flags(chat, user); - cbuddy = gaim_conv_chat_cb_new2(user, alias, flags); + cbuddy = gaim_conv_chat_cb_new(user, alias, flags); add_chat_buddy_common(conv, cbuddy, NULL); g_free(alias); @@ -5878,7 +5831,6 @@ gaim_gtkconv_write_im, /* write_im */ gaim_gtkconv_write_conv, /* write_conv */ gaim_gtkconv_chat_add_users, /* chat_add_users */ - gaim_gtkconv_chat_add_users2, /* chat_add_users */ gaim_gtkconv_chat_rename_user, /* chat_rename_user */ gaim_gtkconv_chat_remove_users, /* chat_remove_users */ gaim_gtkconv_chat_update_user, /* chat_update_user */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |