- commit
- 192c5bd1b123235e14f048499381fbfda0facb59
- parent
- 5f8414edd61f22ada144c074dcec18510007aa4e
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2020-09-05 16:43
perf: optimize filter
Diffstat
| M | cplay.py | 10 | +++++++--- |
1 files changed, 7 insertions, 3 deletions
diff --git a/cplay.py b/cplay.py
@@ -388,19 +388,23 @@ class Filelist(List): 388 388 return results 389 389 390 390 def filter(self, query):391 -1 self.rsearch_str = query392 -1393 391 if not self.search_cache: 394 392 self.search_cache = self.build_search_cache(self.path) 395 393 396 394 if query: -1 395 if self.rsearch_str and query.startswith(self.rsearch_str): -1 396 base = self.items -1 397 else: -1 398 base = self.search_cache -1 399 397 400 self.items = []398 -1 for path in self.search_cache:-1 401 for path in base: 399 402 if str_match(query, self.format_item(path)): 400 403 self.items.append(path) 401 404 else: 402 405 self.items = self.all_items 403 406 -1 407 self.rsearch_str = query 404 408 self.set_cursor(self.cursor) 405 409 406 410 def process_key(self, key):