Browse Source

Use short-circuit evaluation in AndQuery and OrQuery (fix #4145)

pull/4147/head
Julien Cassette 2 months ago
parent
commit
5e6be0ddb3
  1. 4
      beets/dbcore/query.py
  2. 3
      docs/changelog.rst

4
beets/dbcore/query.py

@ -443,7 +443,7 @@ class AndQuery(MutableCollectionQuery):
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):
@ -453,7 +453,7 @@ class OrQuery(MutableCollectionQuery):
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):

3
docs/changelog.rst

@ -73,6 +73,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)
-----------------------

Loading…
Cancel
Save