Use the template cache to speed up evaluation when searching using templates.

This commit is contained in:
Charles Haley 2020-09-23 11:43:50 +01:00 committed by Kovid Goyal
parent ae189e0eee
commit c3867b3473
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -643,9 +643,12 @@ class Parser(SearchQueryParser): # {{{
matchkind, query = _matchkind(query, case_sensitive=case_sensitive) matchkind, query = _matchkind(query, case_sensitive=case_sensitive)
matches = set() matches = set()
error_string = '*@*TEMPLATE_ERROR*@*' error_string = '*@*TEMPLATE_ERROR*@*'
template_cache = {}
for book_id in candidates: for book_id in candidates:
mi = self.dbcache.get_proxy_metadata(book_id) 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): if val.startswith(error_string):
raise ParseException(val[len(error_string):]) raise ParseException(val[len(error_string):])
if sep == 't': if sep == 't':