summaryrefslogtreecommitdiffstats
path: root/mutt.h
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2020-02-08 11:34:13 -0800
committerKevin McCarthy <kevin@8t8.us>2020-02-10 15:30:17 -0800
commit0f8a079d1cc66878ddfa68476f8ea7abdb6fd7e8 (patch)
tree82a09aead8224f619262acff607cce28c36f60da /mutt.h
parent376716eb6fd43982abca56707b809ccd6d8741a6 (diff)
Speed up thread sort when many long threads exist.
Merge request !75 reported a massive slowdown opening a mailbox with many long threads: on the order of an hour. This is because mutt_set_virtual() was iterating through the whole thread for each message. After taking a closer look at current Mutt behavior, it seems the num_hidden count is only needed in the root thread. Quoting my comment in the merge request: The index-format expando %M only applies to root level headers, so there are no issues there. The only concern is the pattern ~v. Limiting always resets collapsed and num_hidden, so there also can't be any issues there. Tagging and other pattern operators only work on visible messages. So tagging while threads are sorted will only tag the root messages of collapsed threads. However, if you sort by thread, collapse a thread, and then sort by date, the collapsed and num_hidden fields are not reset for each header. In theory this would allow us to tag ~v with date ordering. However, in master the num_hidden is only set (by mutt_set_virtual()) for visible messages with a virtual number. So even in master, switching to date-order and tagging ~v will only tag the root messages of each collapsed thread. This commit removes the num_hidden setting in mutt_set_virtual(), instead directly assigning that value in the roothdr during a collapse operation. A subsequent commit will fix the behavior of ~v, when switching sorting from threaded to something else, by putting num_hidden in every header in the thread. This is technically a change in behavior, so I will make that commit in the master branch. Thanks to Score_Under for the pull request and for testing my alternate solutions.
Diffstat (limited to 'mutt.h')
-rw-r--r--mutt.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/mutt.h b/mutt.h
index 836c6c81..60649fac 100644
--- a/mutt.h
+++ b/mutt.h
@@ -203,9 +203,8 @@ typedef enum
#define MUTT_THREAD_COLLAPSE (1<<0)
#define MUTT_THREAD_UNCOLLAPSE (1<<1)
-#define MUTT_THREAD_GET_HIDDEN (1<<2)
-#define MUTT_THREAD_UNREAD (1<<3)
-#define MUTT_THREAD_NEXT_UNREAD (1<<4)
+#define MUTT_THREAD_UNREAD (1<<2)
+#define MUTT_THREAD_NEXT_UNREAD (1<<3)
enum
{
@@ -882,7 +881,9 @@ typedef struct header
/* the following are used to support collapsing threads */
unsigned int collapsed : 1; /* is this message part of a collapsed thread? */
unsigned int limited : 1; /* is this message in a limited view? */
- size_t num_hidden; /* number of hidden messages in this view */
+ size_t num_hidden; /* number of hidden messages in this view.
+ * only valid for the root header, when
+ * collapsed is set. */
short recipient; /* user_is_recipient()'s return value, cached */