[at-spi2-core] Make deferred_messages a GQueue rather than a GList
- From: Mike Gorse <mgorse src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [at-spi2-core] Make deferred_messages a GQueue rather than a GList
- Date: Fri, 27 May 2011 04:39:00 +0000 (UTC)
commit 8ff27574473e6317ee7f7c507e2e0b8897107850
Author: Mike Gorse <mgorse novell com>
Date: Thu May 26 23:03:15 2011 -0500
Make deferred_messages a GQueue rather than a GList
If an application sends a large number of events, then deferred_messages can
become quite large (possibly holding several thousand messages), so appending
to a GList can become a performance hit. Thus, use a GQueue instead.
atspi/atspi-misc.c | 15 +++++++--------
1 files changed, 7 insertions(+), 8 deletions(-)
---
diff --git a/atspi/atspi-misc.c b/atspi/atspi-misc.c
index 4776c06..616dc22 100644
--- a/atspi/atspi-misc.c
+++ b/atspi/atspi-misc.c
@@ -691,21 +691,20 @@ process_deferred_message (BusDataClosure *closure)
}
}
-static GList *deferred_messages = NULL;
+static GQueue *deferred_messages = NULL;
gboolean
_atspi_process_deferred_messages (gpointer data)
{
static int in_process_deferred_messages = 0;
+ BusDataClosure *closure;
if (in_process_deferred_messages)
return TRUE;
in_process_deferred_messages = 1;
- while (deferred_messages != NULL)
+ while (closure = g_queue_pop_head (deferred_messages))
{
- BusDataClosure *closure = deferred_messages->data;
process_deferred_message (closure);
- deferred_messages = g_list_remove (deferred_messages, closure);
dbus_message_unref (closure->message);
dbus_connection_unref (closure->bus);
g_free (closure);
@@ -721,15 +720,12 @@ static DBusHandlerResult
defer_message (DBusConnection *connection, DBusMessage *message, void *user_data)
{
BusDataClosure *closure = g_new (BusDataClosure, 1);
- GList *new_list;
closure->bus = dbus_connection_ref (bus);
closure->message = dbus_message_ref (message);
closure->data = user_data;
- new_list = g_list_append (deferred_messages, closure);
- if (new_list)
- deferred_messages = new_list;
+ g_queue_push_tail (deferred_messages, closure);
if (process_deferred_messages_id == -1)
process_deferred_messages_id = g_idle_add (_atspi_process_deferred_messages, NULL);
@@ -864,6 +860,9 @@ atspi_init (void)
no_cache = g_getenv ("ATSPI_NO_CACHE");
if (no_cache && g_strcmp0 (no_cache, "0") != 0)
atspi_no_cache = TRUE;
+
+ deferred_messages = g_queue_new ();
+
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]