From c3867b34737dc433a72814e543dcf1027150269b Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Wed, 23 Sep 2020 11:43:50 +0100 Subject: [PATCH] Use the template cache to speed up evaluation when searching using templates. --- src/calibre/db/search.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/db/search.py b/src/calibre/db/search.py index c4610bc126..88ca72ee45 100644 --- a/src/calibre/db/search.py +++ b/src/calibre/db/search.py @@ -643,9 +643,12 @@ class Parser(SearchQueryParser): # {{{ matchkind, query = _matchkind(query, case_sensitive=case_sensitive) matches = set() error_string = '*@*TEMPLATE_ERROR*@*' + template_cache = {} for book_id in candidates: mi = self.dbcache.get_proxy_metadata(book_id) - val = mi.formatter.safe_format(template, {}, error_string, mi) + val = mi.formatter.safe_format(template, {}, error_string, mi, + column_name='search template', + template_cache=template_cache) if val.startswith(error_string): raise ParseException(val[len(error_string):]) if sep == 't':