Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache macroList output #11

Closed
MinusGix opened this issue Jan 5, 2021 · 3 comments
Closed

Cache macroList output #11

MinusGix opened this issue Jan 5, 2021 · 3 comments

Comments

@MinusGix
Copy link
Collaborator

MinusGix commented Jan 5, 2021

The macroList function currently does not cache the files.
Since it is called by collect (which is called by SugarCube diagnostics and hover), it can be called pretty often. While not often enough to likely cause notable/visible input lag it is still reads the file and parses it quite often.
Solution: Use https://code.visualstudio.com/api/references/vscode-api#workspace.createFileSystemWatcher with the current glob for json/yaml/yml files, and keep a global variable (exported or not? I'd say no) of the last parsed result. Then macroList simple checks if it already exists. On a file edit/creation/deletion, all it has to do is perform the parsing again.

I can implement this.

@MinusGix
Copy link
Collaborator Author

MinusGix commented Jan 6, 2021

Note: I realized that vscode.workspace.openTextDocument probably keeps the file open so it is not a full disk read every time.
Still, caching the parsing result would be useful, especially if/when more complex checks/transformations need to be applied to the information.

@cyrusfirheir
Copy link
Owner

Agreed! Adds in TODO The the 'list' changes very less, so this would be a lot better.

@cyrusfirheir
Copy link
Owner

Since #13 was merged... Closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants