From c536ae1e0e182ff7cd163bef87990b7e5c0cec21 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Fri, 6 Mar 2009 11:53:32 +0000 Subject: Little optimization of log_store_empathy_get_filtered_messages() and add a FIXME. From: Xavier Claessens svn path=/trunk/; revision=2619 --- libempathy/empathy-log-store-empathy.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'libempathy') diff --git a/libempathy/empathy-log-store-empathy.c b/libempathy/empathy-log-store-empathy.c index 3a924aa53..15a0b2e51 100644 --- a/libempathy/empathy-log-store-empathy.c +++ b/libempathy/empathy-log-store-empathy.c @@ -719,13 +719,16 @@ log_store_empathy_get_filtered_messages (EmpathyLogStore *self, gpointer user_data) { GList *dates, *l, *messages = NULL; + guint i = 0; dates = log_store_empathy_get_dates (self, account, chat_id, chatroom); - for (l = g_list_last (dates); l && g_list_length (messages) < num_messages; l = g_list_previous (l)) + for (l = g_list_last (dates); l && i < num_messages; l = g_list_previous (l)) { GList *new_messages, *n, *next; + /* FIXME: We should really restrict the message parsing to get only + * the newest num_messages. */ new_messages = log_store_empathy_get_messages_for_date (self, account, chat_id, chatroom, l->data); @@ -738,6 +741,10 @@ log_store_empathy_get_filtered_messages (EmpathyLogStore *self, g_object_unref (n->data); new_messages = g_list_delete_link (new_messages, n); } + else + { + i++; + } n = next; } messages = g_list_concat (messages, new_messages); -- cgit v1.2.3