From: Seth Forshee Date: Sun, 26 Apr 2015 02:00:13 +0000 (-0700) Subject: Fix performance regression for ~b/~B searching. (closes #3743) X-Git-Tag: neomutt-20160307~59 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2ced2318d303c22afa7dc8f6d62529d0af8a9f87;p=neomutt Fix performance regression for ~b/~B searching. (closes #3743) In mutt_is_autoview(), changeset b58cdfacfb89 introduced a call to rfc1524_mailcap_lookup() before checking if the MIME type should be autoviewed based on the user's preferences. This caused a major performance regression for ~b/~B searching. Rearrange mutt_is_autoview() to check the user preferences first, then search for a mailcap entry only if the MIME type should be autoviewed. In order to preserve correct mime_lookup behavior, re-add a call to mutt_check_lookup_list() before scanning the AutoViewList. --- diff --git a/handler.c b/handler.c index 9313c1d50..0d71296ca 100644 --- a/handler.c +++ b/handler.c @@ -955,37 +955,39 @@ static int is_mmnoask (const char *buf) static int mutt_is_autoview (BODY *b) { char type[SHORT_STRING]; + int is_autoview = 0; snprintf (type, sizeof (type), "%s/%s", TYPE (b), b->subtype); - /* determine if there is a mailcap entry suitable for auto_view - * - * WARNING: _type is altered by this call as a result of `mime_lookup' support */ - if (rfc1524_mailcap_lookup(b, type, NULL, M_AUTOVIEW)) + if (option(OPTIMPLICITAUTOVIEW)) { - if (option(OPTIMPLICITAUTOVIEW)) - { - /* $implicit_autoview is essentially the same as "auto_view *" */ - return 1; + /* $implicit_autoview is essentially the same as "auto_view *" */ + is_autoview = 1; + } + else + { + /* determine if this type is on the user's auto_view list */ + LIST *t = AutoViewList; + + mutt_check_lookup_list (b, type, sizeof (type)); + for (; t; t = t->next) { + int i = mutt_strlen (t->data) - 1; + if ((i > 0 && t->data[i-1] == '/' && t->data[i] == '*' && + ascii_strncasecmp (type, t->data, i) == 0) || + ascii_strcasecmp (type, t->data) == 0) + is_autoview = 1; } - else - { - /* determine if this type is on the user's auto_view list */ - LIST *t = AutoViewList; - - for (; t; t = t->next) { - int i = mutt_strlen (t->data) - 1; - if ((i > 0 && t->data[i-1] == '/' && t->data[i] == '*' && - ascii_strncasecmp (type, t->data, i) == 0) || - ascii_strcasecmp (type, t->data) == 0) - return 1; - } - if (is_mmnoask (type)) - return 1; - } + if (is_mmnoask (type)) + is_autoview = 1; } + /* determine if there is a mailcap entry suitable for auto_view + * + * WARNING: type is altered by this call as a result of `mime_lookup' support */ + if (is_autoview) + return rfc1524_mailcap_lookup(b, type, NULL, M_AUTOVIEW); + return 0; }