[balsa/thread-date] mailbox: Optimize sorting for flat index
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/thread-date] mailbox: Optimize sorting for flat index
- Date: Sun, 5 Aug 2018 16:04:13 +0000 (UTC)
commit 2039c3f99d442e3c979b3613cbbb3696c0ff752f
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Sun Aug 5 12:01:22 2018 -0400
mailbox: Optimize sorting for flat index
Use the message-date for sorting when the index is flat (unthreaded),
instead of traversing a one-node tree to find the same date.
libbalsa/mailbox.c | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
---
diff --git a/libbalsa/mailbox.c b/libbalsa/mailbox.c
index ee4c2b4d2..dbab60eb7 100644
--- a/libbalsa/mailbox.c
+++ b/libbalsa/mailbox.c
@@ -3333,6 +3333,13 @@ mbox_compare_subject(LibBalsaMailboxIndexEntry * message_a,
return g_ascii_strcasecmp(message_a->subject, message_b->subject);
}
+static gint
+mbox_compare_date(LibBalsaMailboxIndexEntry * message_a,
+ LibBalsaMailboxIndexEntry * message_b)
+{
+ return message_a->msg_date - message_b->msg_date;
+}
+
/* Thread date stuff */
typedef struct {
@@ -3380,9 +3387,9 @@ mbox_get_thread_date(const SortTuple *tuple,
}
static gint
-mbox_compare_date(const SortTuple *a,
- const SortTuple *b,
- LibBalsaMailbox *mbox)
+mbox_compare_thread_date(const SortTuple *a,
+ const SortTuple *b,
+ LibBalsaMailbox *mbox)
{
return mbox_get_thread_date(a, mbox) - mbox_get_thread_date(b, mbox);
}
@@ -3427,7 +3434,10 @@ mbox_compare_func(const SortTuple * a,
retval = mbox_compare_subject(message_a, message_b);
break;
case LB_MAILBOX_SORT_DATE:
- retval = mbox_compare_date(a, b, mbox);
+ retval =
+ mbox->view->threading_type == LB_MAILBOX_THREADING_FLAT
+ ? mbox_compare_date(message_a, message_b)
+ : mbox_compare_thread_date(a, b, mbox);
break;
case LB_MAILBOX_SORT_SIZE:
retval = mbox_compare_size(message_a, message_b);
@@ -3447,7 +3457,10 @@ mbox_compare_func(const SortTuple * a,
retval = mbox_compare_subject(message_a, message_b);
break;
case LB_MAILBOX_SORT_DATE:
- retval = mbox_compare_date(a, b, mbox);
+ retval =
+ mbox->view->threading_type == LB_MAILBOX_THREADING_FLAT
+ ? mbox_compare_date(message_a, message_b)
+ : mbox_compare_thread_date(a, b, mbox);
break;
case LB_MAILBOX_SORT_SIZE:
retval = mbox_compare_size(message_a, message_b);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]