Mercurial > pidgin.yaz
changeset 32368:6283c0f2b02f
Change PurpleNotifyUserInfo->user_info_entries from a GList to a GQueue.
This makes appending fast.
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 22 Aug 2011 04:14:16 +0000 |
parents | a686269689fe |
children | 0ee025d8686e |
files | finch/gntnotify.c libpurple/notify.c libpurple/notify.h libpurple/plugins/perl/common/Notify.xs libpurple/protocols/jabber/buddy.c |
diffstat | 5 files changed, 30 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/finch/gntnotify.c Mon Aug 22 03:40:04 2011 +0000 +++ b/finch/gntnotify.c Mon Aug 22 04:14:16 2011 +0000 @@ -290,7 +290,7 @@ 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);
--- a/libpurple/notify.c Mon Aug 22 03:40:04 2011 +0000 +++ b/libpurple/notify.c Mon Aug 22 04:14:16 2011 +0000 @@ -53,7 +53,7 @@ struct _PurpleNotifyUserInfo { - GList *user_info_entries; + GQueue user_info_entries; }; void * @@ -454,7 +454,7 @@ 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 @@ { 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 *
--- a/libpurple/notify.h Mon Aug 22 03:40:04 2011 +0000 +++ b/libpurple/notify.h Mon Aug 22 04:14:16 2011 +0000 @@ -439,20 +439,20 @@ * 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
--- a/libpurple/plugins/perl/common/Notify.xs Mon Aug 22 03:40:04 2011 +0000 +++ b/libpurple/plugins/perl/common/Notify.xs Mon Aug 22 04:14:16 2011 +0000 @@ -135,7 +135,7 @@ 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"))); }
--- a/libpurple/protocols/jabber/buddy.c Mon Aug 22 03:40:04 2011 +0000 +++ b/libpurple/protocols/jabber/buddy.c Mon Aug 22 04:14:16 2011 +0000 @@ -806,7 +806,7 @@ 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) */