1
Fix performance regression for ~b/~B searching. (closes #3743)
3
In mutt_is_autoview(), changeset b58cdfacfb89 introduced a call to
4
rfc1524_mailcap_lookup() before checking if the MIME type should
5
be autoviewed based on the user's preferences. This caused a major
6
performance regression for ~b/~B searching.
8
Rearrange mutt_is_autoview() to check the user preferences first, then
9
search for a mailcap entry only if the MIME type should be autoviewed.
11
In order to preserve correct mime_lookup behavior, re-add a call to
12
mutt_check_lookup_list() before scanning the AutoViewList.
14
diff -r 067a3ac42c3b -r 755a18da99bc handler.c
15
--- a/handler.c Sun Apr 19 13:15:50 2015 -0700
16
+++ b/handler.c Sat Apr 25 19:00:13 2015 -0700
18
static int mutt_is_autoview (BODY *b)
20
char type[SHORT_STRING];
21
+ int is_autoview = 0;
23
snprintf (type, sizeof (type), "%s/%s", TYPE (b), b->subtype);
25
+ if (option(OPTIMPLICITAUTOVIEW))
27
+ /* $implicit_autoview is essentially the same as "auto_view *" */
32
+ /* determine if this type is on the user's auto_view list */
33
+ LIST *t = AutoViewList;
35
+ mutt_check_lookup_list (b, type, sizeof (type));
36
+ for (; t; t = t->next) {
37
+ int i = mutt_strlen (t->data) - 1;
38
+ if ((i > 0 && t->data[i-1] == '/' && t->data[i] == '*' &&
39
+ ascii_strncasecmp (type, t->data, i) == 0) ||
40
+ ascii_strcasecmp (type, t->data) == 0)
44
+ if (is_mmnoask (type))
48
/* determine if there is a mailcap entry suitable for auto_view
50
- * WARNING: _type is altered by this call as a result of `mime_lookup' support */
51
- if (rfc1524_mailcap_lookup(b, type, NULL, M_AUTOVIEW))
53
- if (option(OPTIMPLICITAUTOVIEW))
55
- /* $implicit_autoview is essentially the same as "auto_view *" */
60
- /* determine if this type is on the user's auto_view list */
61
- LIST *t = AutoViewList;
63
- for (; t; t = t->next) {
64
- int i = mutt_strlen (t->data) - 1;
65
- if ((i > 0 && t->data[i-1] == '/' && t->data[i] == '*' &&
66
- ascii_strncasecmp (type, t->data, i) == 0) ||
67
- ascii_strcasecmp (type, t->data) == 0)
71
- if (is_mmnoask (type))
75
+ * WARNING: type is altered by this call as a result of `mime_lookup' support */
77
+ return rfc1524_mailcap_lookup(b, type, NULL, M_AUTOVIEW);