Skip to content

Conversation

@superle3
Copy link
Collaborator

optimize snippet expansion and runSnippetCursor.

It doesn't differ that much from 0.5-0.7ms to 0.2-0.3ms, but running regex first and then excluded environments is faster in math.

The ShouldRunInSnippetMode is better if its first for text and worse for math, probably because there are more math snippets but it doesn't differ that much that it should be changed.

For expansion:

view.dispatch is very slow for large documents so adding to the queue, adding tabstops, replacing the snippet syntax and inserting the replacement is all done in one call now.

Its still 2 calls for automatic snippets and it could be maybe be done in one call by changing the code that handles when a snippet is undone and redone, but I don't currently have an idea how I would implement that.

`view.dispatch` calls are expensive for large documents,
so a few commits to reduce them.
Improvement 1:
improve snippet performance by removing `view.dispatch` for queueing and
clearing snippets to the snippetQueue. A `view.dispatch` for queueing
and clearing snippets can get up to 10~11ms.
The snippetQueue doesn't need to be in a `StateField` to function,
so now its a regular class.

To preserve functionality, the queue is readonly, but no functional
reason I think.
Improve snippet expansion performance by reducing `view.dispatch` calls.
Improvement 2:
Merge adding the tabstops and inserting the changes into the document in
one `view.dispatch` call.

Since tabstops were added first, now the changes are applied after
adding the tabstops.
Improve snippet expansion by reducing `view.dispatch` calls.
Improvement 3:
Merging placing the snippets down and converting the tabstops syntax to actual snippets
To convert the syntax, the changes have to applied separately and
applying the changes to the old tabstops now happens before the new
tabstops are inserted.

The final 2 `view.dispatch` in `expandSnippets` could be merged by
altering the undo and redo behaviour and inserting the keys in the
automatic snippets back in.
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

Successfully merging this pull request may close these issues.

1 participant