summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Laban <david.laban@collabora.co.uk>2011-05-17 20:06:38 -0400
committerDavid Laban <david.laban@collabora.co.uk>2011-05-17 20:06:38 -0400
commitdc17262c8b8690801b76b62caa8d7cb78ad11a2f (patch)
tree630b66c31e6d1bebd59b8be99c060bc5148ca9f9
parent72da94f04198dc07f8161b54e56a336a29678255 (diff)
downloadtelepathy-logger-dc17262c8b8690801b76b62caa8d7cb78ad11a2f.tar.gz
Extract an event_queue_insert_sorted_after utility function
Like g_queue_insert_sorted, but with the shortcut of not having to search from the beginning of the queue all the time, and the simplification of knowing that we are always dealing with TplEvents.
-rw-r--r--telepathy-logger/log-store-xml.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/telepathy-logger/log-store-xml.c b/telepathy-logger/log-store-xml.c
index 152f328..045cdb9 100644
--- a/telepathy-logger/log-store-xml.c
+++ b/telepathy-logger/log-store-xml.c
@@ -1239,6 +1239,28 @@ parse_call_node (TplLogStoreXml *self,
return event;
}
+static GList *
+event_queue_insert_sorted_after (GQueue *events,
+ GList *index,
+ TplEvent *event)
+{
+ while (index != NULL &&
+ tpl_event_get_timestamp (event) <
+ tpl_event_get_timestamp (TPL_EVENT (index->data)))
+ index = g_list_next (index);
+
+ if (index != NULL)
+ {
+ g_queue_insert_after (events, index, event);
+ return g_list_next (index);
+ }
+ else
+ {
+ g_queue_push_tail (events, event);
+ return events->head;
+ }
+}
+
/* returns a Glist of TplEvent instances */
static void
log_store_xml_get_events_for_file (TplLogStoreXml *self,
@@ -1335,22 +1357,7 @@ log_store_xml_get_events_for_file (TplLogStoreXml *self,
if (event != NULL)
{
- while (index != NULL &&
- tpl_event_get_timestamp (event) <
- tpl_event_get_timestamp (TPL_EVENT (index->data)))
- index = g_list_next (index);
-
- if (index != NULL)
- {
- g_queue_insert_after (events, index, event);
- index = g_list_next (index);
- }
- else
- {
- g_queue_push_tail (events, event);
- index = events->head;
- }
-
+ index = event_queue_insert_sorted_after (events, index, event);
num_events++;
}
}