obsidian-vimrc-support icon indicating copy to clipboard operation
obsidian-vimrc-support copied to clipboard

Performance concern

Open lishid opened this issue 2 years ago • 3 comments

https://github.com/esm7/obsidian-vimrc-support/blob/8ab389c73e98d5ff82d850656d4150a1ba4fb63c/main.ts#L79 Here you are reading and re-parsing the vimrc file whenever the user opens a file, or switches pane. Maybe there's a better way so it doesn't get loaded as often?

lishid avatar Dec 07 '21 22:12 lishid

Hmm the plugin also doesn't gracefully unload and remove all the hooks that it has attached when the user disables the plugin.

lishid avatar Dec 07 '21 22:12 lishid

Regarding the performance concern:

  1. It's easy to have the vimrc file read only once, and build a parsed list of actions that get done on every new CM instance from that point onward. I didn't originally go down that road because it seemed to me like users' vimrc files are going to very short anyway, so I chose simplicity over an optimization that felt unneeded in practice. What do you think?
  2. The fact this happens when switching a pane is completely redundant and I'll take care of it.

Re the unload, will fix ASAP.

esm7 avatar Dec 08 '21 06:12 esm7

  1. Fair enough. I think that's fine then. You could add a small check for whether the file contents has changed since last parse, or stat the file and check for mtime change, but if they're short anyway then it's probably fine.

lishid avatar Dec 08 '21 06:12 lishid