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-show.el | 1 + 1 file changed, 1 insertion(+) (limited to 'emacs/notmuch-show.el') diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index b8782ddb..019f51d7 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -1145,6 +1145,7 @@ function is used." ;; Don't track undo information for this buffer (set 'buffer-undo-list t) + (notmuch-tag-clear-cache) (erase-buffer) (goto-char (point-min)) (save-excursion -- cgit v1.2.3