From d93b8135a6df276fefd9c07ddab14aa12a53515b Mon Sep 17 00:00:00 2001 From: Jakub Sitnicki Date: Mon, 7 Jul 2014 06:22:57 +0200 Subject: [PATCH] Revert "* bugfix for issue 164" This reverts commit c7b28419abd9d53ff36412e4fedaf308ce13c552. The reverted change fails to sort threads correctly when there is an empty container, serving as a parent to orphan messages, in the thread tree as demonstrated by the test in commit f49296759ef8 ("tests: threads: Test if orphan message promotes its thread"). Also, the reverted commit introduces a performance hit. The time it takes to sort threads has increased roughly by a factor of 4. Current state: $ perf stat --event=task-clock --repeat=10 -- \ mu find maildir:/INBOX -n 1 -t > /dev/null Performance counter stats for 'mu find maildir:/INBOX -n 1 -t' (10 runs): 4967.692519 task-clock (msec) # 1.000 CPUs utilized ( +- 0.14% ) 4.969247128 seconds time elapsed ( +- 0.14% ) With the reverted patch applied: $ perf stat --event=task-clock --repeat=10 -- \ mu find maildir:/INBOX -n 1 -t > /dev/null Performance counter stats for 'mu find maildir:/INBOX -n 1 -t' (10 runs): 1231.761588 task-clock (msec) # 0.996 CPUs utilized ( +- 1.02% ) 1.236209133 seconds time elapsed ( +- 1.08% ) The benchmark was ran on a maildir with ~16k messages: $ mu find maildir:/INBOX | wc -l 16503 --- lib/mu-container.c | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/lib/mu-container.c b/lib/mu-container.c index ec7b3795..34db96a5 100644 --- a/lib/mu-container.c +++ b/lib/mu-container.c @@ -317,22 +317,6 @@ struct _SortFuncData { }; typedef struct _SortFuncData SortFuncData; -static MuContainer* -get_top_msg (MuContainer *c, MuMsgFieldId mfid) -{ - MuContainer *piv, *extreme = c; - for (piv = c; piv != NULL && piv->msg != NULL; piv = piv->child) { - if (mu_msg_cmp (piv->msg, extreme->msg, mfid) > 0) - extreme = piv; - if (piv != c && piv->next) { - MuContainer *sub = get_top_msg (piv->next, mfid); - - if (sub->msg != NULL && mu_msg_cmp (sub->msg, extreme->msg, mfid) > 0) - extreme = sub; - } - } - return extreme; -} static int sort_func_wrapper (MuContainer *a, MuContainer *b, SortFuncData *data) @@ -344,9 +328,6 @@ sort_func_wrapper (MuContainer *a, MuContainer *b, SortFuncData *data) for (a1 = a; a1->msg == NULL && a1->child != NULL; a1 = a1->child); for (b1 = b; b1->msg == NULL && b1->child != NULL; b1 = b1->child); - a1 = get_top_msg (a1, data->mfid); - b1 = get_top_msg (b1, data->mfid); - if (a1 == b1) return 0; else if (!a1->msg)