This commit is contained in:
Kovid Goyal 2020-10-04 18:08:49 +05:30
parent 86d0715e71
commit e6c651c5bf
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 4 additions and 4 deletions

View File

@ -926,7 +926,7 @@ class Search(object):
finally:
sqp.dbcache = sqp.lookup_saved_search = None
def _use_cache(self, sqp, dbcache, query):
def query_is_cacheable(self, sqp, dbcache, query):
if query:
for name, value in sqp.get_queried_fields(query):
if name == 'template' and '#@#:d:' in value:
@ -949,7 +949,7 @@ class Search(object):
query = query.decode('utf-8')
query = query.strip()
use_cache = self._use_cache(sqp, dbcache, query)
use_cache = self.query_is_cacheable(sqp, dbcache, query)
if use_cache and book_ids is None and query and not search_restriction:
cached = self.cache.get(query)
@ -960,7 +960,7 @@ class Search(object):
if search_restriction and search_restriction.strip():
sr = search_restriction.strip()
sqp.all_book_ids = all_book_ids if book_ids is None else book_ids
if self._use_cache(sqp, dbcache, sr):
if self.query_is_cacheable(sqp, dbcache, sr):
cached = self.cache.get(sr)
if cached is None:
restricted_ids = sqp.parse(sr)

View File

@ -351,7 +351,7 @@ class SearchQueryParser(object):
yield from self._walk_expr(self._get_tree(
self._get_saved_search_text(tree[2])))
else:
yield (tree[1], tree[2])
yield tree[1], tree[2]
def parse(self, query, candidates=None):
# empty the list of searches used for recursion testing