From 7023466ece21b43a62dc0a2502e84bea78b1501c Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Sat, 22 Mar 2014 11:51:06 +0000 Subject: Make keys of notmuch-tag-formats regexps and use caching This modifies `notmuch-tag-format-tag' to treat the keys of `notmuch-tag-formats' as (anchored) regexps, rather than literal strings. This is clearly more flexible, as it allows for prefix matching, defining a fallback format, etc. This may cause compatibility problems if people have customized `notmuch-tag-formats' to match tags that contain regexp specials, but this seems unlikely. Regular expression matching has quite a performance hit over string lookup, so this also introduces a simple cache from exact tags to formatted strings. The number of unique tags is likely to be quite small, so this cache should have a high hit rate. In addition to eliminating the regexp lookup in the common case, this cache stores fully formatted tags, eliminating the repeated evaluation of potentially expensive, user-specified formatting code. This makes regexp lookup at least as fast as assoc for unformatted tags (e.g., inbox) and *faster* than the current code for formatted tags (e.g., unread): inbox (usec) unread (usec) assoc: 0.4 2.8 regexp: 3.2 7.2 regexp+caching: 0.4 0.4 (Though even at 7.2 usec, tag formatting is not our top bottleneck.) This cache must be explicitly cleared to keep it coherent, so this adds the appropriate clearing calls. --- emacs/notmuch.el | 1 + 1 file changed, 1 insertion(+) (limited to 'emacs/notmuch.el') diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 9e39a76b..2e0b20eb 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -888,6 +888,7 @@ the configured default sort order." (set 'notmuch-search-oldest-first oldest-first) (set 'notmuch-search-target-thread target-thread) (set 'notmuch-search-target-line target-line) + (notmuch-tag-clear-cache) (let ((proc (get-buffer-process (current-buffer))) (inhibit-read-only t)) (if proc -- cgit v1.2.3