pidgin: 0ea4521b: Change PurpleNotifyUserInfo->user_info_e...
markdoliner at pidgin.im
markdoliner at pidgin.im
Mon Aug 22 00:21:39 EDT 2011
----------------------------------------------------------------------
Revision: 0ea4521b22507f8cc23de316fa55e3368d9f4029
Parent: ac7e7c8767be76d067401a4883f91e8f0cca1f71
Author: markdoliner at pidgin.im
Date: 08/22/11 00:14:16
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/0ea4521b22507f8cc23de316fa55e3368d9f4029
Changelog:
Change PurpleNotifyUserInfo->user_info_entries from a GList to a GQueue.
This makes appending fast.
Changes against parent ac7e7c8767be76d067401a4883f91e8f0cca1f71
patched finch/gntnotify.c
patched libpurple/notify.c
patched libpurple/notify.h
patched libpurple/plugins/perl/common/Notify.xs
patched libpurple/protocols/jabber/buddy.c
-------------- next part --------------
============================================================
--- libpurple/notify.c 63418436656841ae28473e277f41c06b9b9ad061
+++ libpurple/notify.c d97e3742d65265693e2c025ae30b59383b7b8a55
@@ -53,7 +53,7 @@ struct _PurpleNotifyUserInfo
struct _PurpleNotifyUserInfo
{
- GList *user_info_entries;
+ GQueue user_info_entries;
};
void *
@@ -454,7 +454,7 @@ purple_notify_user_info_new()
user_info = g_new0(PurpleNotifyUserInfo, 1);
PURPLE_DBUS_REGISTER_POINTER(user_info, PurpleNotifyUserInfo);
- user_info->user_info_entries = NULL;
+ g_queue_init(&user_info->user_info_entries);
return user_info;
}
@@ -464,23 +464,23 @@ purple_notify_user_info_destroy(PurpleNo
{
GList *l;
- for (l = user_info->user_info_entries; l != NULL; l = l->next) {
+ for (l = user_info->user_info_entries.head; l != NULL; l = l->next) {
PurpleNotifyUserInfoEntry *user_info_entry = l->data;
purple_notify_user_info_entry_destroy(user_info_entry);
}
- g_list_free(user_info->user_info_entries);
+ g_queue_clear(&user_info->user_info_entries);
PURPLE_DBUS_UNREGISTER_POINTER(user_info);
g_free(user_info);
}
-GList *
+GQueue *
purple_notify_user_info_get_entries(PurpleNotifyUserInfo *user_info)
{
g_return_val_if_fail(user_info != NULL, NULL);
- return user_info->user_info_entries;
+ return &user_info->user_info_entries;
}
char *
@@ -491,7 +491,7 @@ purple_notify_user_info_get_text_with_ne
text = g_string_new("");
- for (l = user_info->user_info_entries; l != NULL; l = l->next) {
+ for (l = user_info->user_info_entries.head; l != NULL; l = l->next) {
PurpleNotifyUserInfoEntry *user_info_entry = l->data;
/* Add a newline before a section header */
if (user_info_entry->type == PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER)
@@ -580,7 +580,7 @@ purple_notify_user_info_add_pair_html(Pu
PurpleNotifyUserInfoEntry *entry;
entry = purple_notify_user_info_entry_new(label, value);
- user_info->user_info_entries = g_list_append(user_info->user_info_entries, entry);
+ g_queue_push_tail(&user_info->user_info_entries, entry);
}
void
@@ -599,7 +599,7 @@ purple_notify_user_info_prepend_pair(Pur
PurpleNotifyUserInfoEntry *entry;
entry = purple_notify_user_info_entry_new(label, value);
- user_info->user_info_entries = g_list_prepend(user_info->user_info_entries, entry);
+ g_queue_push_head(&user_info->user_info_entries, entry);
}
void
@@ -608,7 +608,7 @@ purple_notify_user_info_remove_entry(Pur
g_return_if_fail(user_info != NULL);
g_return_if_fail(entry != NULL);
- user_info->user_info_entries = g_list_remove(user_info->user_info_entries, entry);
+ g_queue_remove(&user_info->user_info_entries, entry);
}
void
@@ -619,7 +619,7 @@ purple_notify_user_info_add_section_head
entry = purple_notify_user_info_entry_new(label, NULL);
entry->type = PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER;
- user_info->user_info_entries = g_list_append(user_info->user_info_entries, entry);
+ g_queue_push_tail(&user_info->user_info_entries, entry);
}
void
@@ -630,7 +630,7 @@ purple_notify_user_info_prepend_section_
entry = purple_notify_user_info_entry_new(label, NULL);
entry->type = PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER;
- user_info->user_info_entries = g_list_prepend(user_info->user_info_entries, entry);
+ g_queue_push_head(&user_info->user_info_entries, entry);
}
void
@@ -641,7 +641,7 @@ purple_notify_user_info_add_section_brea
entry = purple_notify_user_info_entry_new(NULL, NULL);
entry->type = PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK;
- user_info->user_info_entries = g_list_append(user_info->user_info_entries, entry);
+ g_queue_push_tail(&user_info->user_info_entries, entry);
}
void
@@ -652,17 +652,17 @@ purple_notify_user_info_prepend_section_
entry = purple_notify_user_info_entry_new(NULL, NULL);
entry->type = PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK;
- user_info->user_info_entries = g_list_prepend(user_info->user_info_entries, entry);
+ g_queue_push_head(&user_info->user_info_entries, entry);
}
void
purple_notify_user_info_remove_last_item(PurpleNotifyUserInfo *user_info)
{
- GList *last = g_list_last(user_info->user_info_entries);
- if (last) {
- purple_notify_user_info_entry_destroy(last->data);
- user_info->user_info_entries = g_list_delete_link(user_info->user_info_entries, last);
- }
+ PurpleNotifyUserInfoEntry *entry;
+
+ entry = g_queue_pop_tail(&user_info->user_info_entries);
+ if (entry)
+ purple_notify_user_info_entry_destroy(entry);
}
void *
============================================================
--- libpurple/notify.h 962debbef8f5772977725c5d40ad4f0945c6c9fc
+++ libpurple/notify.h d6cd3118f273ef9b2e9bd6997df553eadc333bb3
@@ -439,20 +439,20 @@ void purple_notify_user_info_destroy(Pur
* Retrieve the array of PurpleNotifyUserInfoEntry objects from a
* PurpleNotifyUserInfo
*
- * This GList may be manipulated directly with normal GList functions such
- * as g_list_insert(). Only PurpleNotifyUserInfoEntry are allowed in the
- * list. If a PurpleNotifyUserInfoEntry item is added to the list, it
- * should not be g_free()'d by the caller; PurpleNotifyUserInfo will g_free
- * it when destroyed.
+ * This GQueue may be manipulated directly with normal GQueue functions such
+ * as g_queue_push_tail(). Only PurpleNotifyUserInfoEntry are allowed in the
+ * queue. If a PurpleNotifyUserInfoEntry item is added to the queue, it
+ * should not be freed by the caller; PurpleNotifyUserInfo will free it when
+ * destroyed.
*
* To remove a PurpleNotifyUserInfoEntry, use
- * purple_notify_user_info_remove_entry(). Do not use the GList directly.
+ * purple_notify_user_info_remove_entry(). Do not use the GQueue directly.
*
* @param user_info The PurpleNotifyUserInfo
*
- * @constreturn A GList of PurpleNotifyUserInfoEntry objects
+ * @constreturn A GQueue of PurpleNotifyUserInfoEntry objects.
*/
-GList *purple_notify_user_info_get_entries(PurpleNotifyUserInfo *user_info);
+GQueue *purple_notify_user_info_get_entries(PurpleNotifyUserInfo *user_info);
/**
* Create a textual representation of a PurpleNotifyUserInfo, separating
============================================================
--- libpurple/protocols/jabber/buddy.c 6fe8c5115c4b17c65cf014d969afaea63562d770
+++ libpurple/protocols/jabber/buddy.c a27963457bbff0bb49ebb52b0ecef3a23278110a
@@ -806,7 +806,7 @@ static void jabber_buddy_info_show_if_re
resource_name = jabber_get_resource(jbi->jid);
/* If we have one or more pairs from the vcard, put a section break above it */
- if (purple_notify_user_info_get_entries(user_info))
+ if (g_queue_get_length(purple_notify_user_info_get_entries(user_info)))
purple_notify_user_info_prepend_section_break(user_info);
/* Add the information about the user's resource(s) */
============================================================
--- libpurple/plugins/perl/common/Notify.xs 627643ffd0e13b46535e2327fb6d6288c659aeb1
+++ libpurple/plugins/perl/common/Notify.xs 5f51d009f95058b17746688436fc9aaaf4b5e787
@@ -135,7 +135,7 @@ PPCODE:
PREINIT:
GList *l;
PPCODE:
- l = purple_notify_user_info_get_entries(user_info);
+ l = purple_notify_user_info_get_entries(user_info)->head;
for (; l != NULL; l = l->next) {
XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::NotifyUserInfoEntry")));
}
============================================================
--- finch/gntnotify.c 1d73fe80756b1d7faf67a3986d9780162292743b
+++ finch/gntnotify.c ca4b536f8cb0e2f5416945986a6722d30f9ddad6
@@ -290,7 +290,7 @@ purple_notify_user_info_get_xhtml(Purple
text = g_string_new("<span>");
- for (l = purple_notify_user_info_get_entries(user_info); l != NULL;
+ for (l = purple_notify_user_info_get_entries(user_info)->head; l != NULL;
l = l->next) {
PurpleNotifyUserInfoEntry *user_info_entry = l->data;
PurpleNotifyUserInfoEntryType type = purple_notify_user_info_entry_get_type(user_info_entry);
More information about the Commits
mailing list