Skip to content

Commit

Permalink
Merge pull request #4147 from jcassette/query-perf
Browse files Browse the repository at this point in the history
Use short-circuit evaluation in AndQuery and OrQuery (fix #4145)
  • Loading branch information
sampsyo authored Nov 17, 2021
2 parents b7d0ddf + 5e6be0d commit 281eec8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions beets/dbcore/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ def clause(self):
return self.clause_with_joiner('and')

def match(self, item):
return all([q.match(item) for q in self.subqueries])
return all(q.match(item) for q in self.subqueries)


class OrQuery(MutableCollectionQuery):
Expand All @@ -453,7 +453,7 @@ def clause(self):
return self.clause_with_joiner('or')

def match(self, item):
return any([q.match(item) for q in self.subqueries])
return any(q.match(item) for q in self.subqueries)


class NotQuery(Query):
Expand Down
3 changes: 3 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ Bug fixes:
* :doc:`/dev/library`: Use slow queries for flexible attributes in aunique.
:bug:`2678` :bug:`3553`

* :doc:`/reference/query`: Use short-circuit evaluation in AndQuery and OrQuery
:bug:`4145`

1.5.0 (August 19, 2021)
-----------------------

Expand Down

0 comments on commit 281eec8

Please sign in to comment.