-
-
Notifications
You must be signed in to change notification settings - Fork 242
Description
Performance issue when frequently modifying view settings
Recently I am working on a package with the following sublime_plugin.ViewEventListener
class FooBar(sublime_plugin.ViewEventListener):
@classmethod
def is_applicable(cls, settings):
print("checked")
return TrueAnd I notice that the method is_applicable is called exactly two times when I move the cursor. I thus change
print("checked") to print(traceback.print_stack()) to see what functions are calling this frequently.
File "bh_core in /Users/Randy/Dropbox/Sublime Text 3/Installed Packages/BracketHighlighter.sublime-package", line 1112, in payload
File "bh_core in /Users/Randy/Dropbox/Sublime Text 3/Installed Packages/BracketHighlighter.sublime-package", line 443, in match
File "/Applications/Sublime Text.app/Contents/MacOS/sublime.py", line 1149, in set
sublime_api.settings_set(self.settings_id, key, value)
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 280, in <lambda>
lambda: check_view_event_listeners(view))
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 267, in check_view_event_listeners
want = is_view_event_listener_applicable(cls, view)
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 232, in is_view_event_listener_applicable
if not cls.is_applicable(view.settings()):
File "/Users/Randy/Dropbox/Sublime Text 3/Packages/LaTeXYZ/preview_math.py", line 14, in is_applicable
print(traceback.print_stack())
It seems that every time I moved the cursor, BH changes the value of a view setting bracket_highlighter.busy twice, from False to True then False again. Each change triggers sublime_plugin.check_view_event_listeners and it then checks if all the ViewEventListener's are applicable to the current view.
There is no problem for doing so, except when a user has a considerable large amount of
ViewEventListener's and each move will take a non-negligible a time / computer power to finish.
Support Info
- ST ver.: 3142
- Platform: osx
- Arch: x64
- Plugin ver.: 2.25.0
- Install via PC: True
- mdpopups ver.: 2.1.1
- backrefs ver.: 1.0.post1
- markdown ver.: 2.6.6
- pygments ver.: 2.1a0
- jinja2 ver.: 2.8
Possible solution!?
BH should avoid using a view setting to flag its working status, may be a global variable?