mirror of
https://github.com/beetbox/beets.git
synced 2026-01-05 23:43:31 +01:00
playlist: Improve speed in PlaylistQuery class
Implement the col_clause method for faster, sqlite-based querying. This will only make a difference if the "fast" kwarg is set to True.
This commit is contained in:
parent
a80a07f093
commit
19b92e1199
1 changed files with 9 additions and 1 deletions
|
|
@ -19,7 +19,7 @@ import beets
|
|||
class PlaylistQuery(beets.dbcore.FieldQuery):
|
||||
"""Matches files listed by a playlist file.
|
||||
"""
|
||||
def __init__(self, field, pattern, fast=False):
|
||||
def __init__(self, field, pattern, fast=True):
|
||||
super(PlaylistQuery, self).__init__(field, pattern, fast)
|
||||
config = beets.config['playlist']
|
||||
|
||||
|
|
@ -51,6 +51,14 @@ class PlaylistQuery(beets.dbcore.FieldQuery):
|
|||
os.path.join(relative_to, line.rstrip())
|
||||
))
|
||||
|
||||
def col_clause(self):
|
||||
if not self.paths:
|
||||
# Playlist is empty
|
||||
return '0', ()
|
||||
clause = 'BYTELOWER(path) IN ({0})'.format(
|
||||
', '.join('BYTELOWER(?)' for path in self.paths))
|
||||
return clause, (beets.library.BLOB_TYPE(p) for p in self.paths)
|
||||
|
||||
def match(self, item):
|
||||
return item.path in self.paths
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue