Skip to content

Commit

Permalink
Refactor compile_filters
Browse files Browse the repository at this point in the history
1. No need to convert dictionary items() to a list().
2. Reduce API calls
  • Loading branch information
deathaxe committed Jan 17, 2024
1 parent e797714 commit 23e593d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions plugins/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ def get_lang_setting(source):


def compile_filters(view):
filters = []
for selector, regexes in list(setting("filters", {}).items()):
if view.match_selector(view.sel() and view.sel()[0].begin() or 0, selector):
filters.append(regexes)
return filters
pt = view.sel() and view.sel()[0].begin() or 0
return [
regexes
for selector, regexes in setting("filters", {}).items()
if view.match_selector(pt, selector)
]

0 comments on commit 23e593d

Please sign in to comment.