Optimizes runSnippetCursor in run_snippet.ts by reducing redundant calls to view.state.sliceDoc.
Partially solves #320 by improving the editting of large files.
Performance Testing
Tested with a large markdown file generated with the following command:
python -c "print('aa\n'*4000)" > test.md
Pushed a key when the cursor is at the bottom of the file and measured the time spent handling the keydown event using DevTools.
Test Environment:
OS: Microsoft Windows 11 Home
CPU: Intel(R) Core(TM) i7-8750H CPU
RAM: 16GB
Results:
Before the update: Handling a single keydown event took approximately 50ms, with runSnippetCursor consuming 47ms.
After the update: Handling a single keydown event took approximately 3ms, with runSnippetCursor consuming 0.2ms.
Optimizes
runSnippetCursor
inrun_snippet.ts
by reducing redundant calls toview.state.sliceDoc
. Partially solves #320 by improving the editting of large files.Performance Testing
Tested with a large markdown file generated with the following command:
Pushed a key when the cursor is at the bottom of the file and measured the time spent handling the keydown event using DevTools.
Test Environment:
Results:
runSnippetCursor
consuming 47ms.runSnippetCursor
consuming 0.2ms.