Bug: improve speed of getBlocks()
kjk opened this issue · comments
On large documents (say 300 kB with multiple blocks) getBlocks()
is called every time delete happens.
It forces syntax parsing of the whole document which can be slow. In my test document it would take > 300 ms. During that time the document is shown un-styled, meaning heynote markings would show for a while.
This was reported on my fork kjk#22 and I fixed it by rewriting getBlocks()
to use string.indexOf()
, which made it run under 2 ms.
The commit is kjk@701dda8, feel free to take this code or disregard.
Nice! This has now been fixed in #241. I ended up with a solution that uses the syntax tree if it's available, and otherwise use String.indexOf()
.