You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(perf): Improve speed of table parsing by storing state
## Details
When handling a pipe_table there are 2 slower parts. For each cell
we compute the amount of space that is concealed & that amount of
inline text added back so we can pad things nicely.
For the amount of concealed space, this was improved earlier by
pre-computing all the concealed nodes at the start of the parse
method. However we can further improve this by implementing our
own node contains logic. I am unsure why this ends up being faster,
but it is quite substantial. We further improve this by storing only
the column range for each node in the cache, and not the entire node.
For the latter we had yet to do anything. The computation here involved
running a treesitter query and essentially computing exactly what we
think the inline parser would add to each cell. Instead what we can do is
store some metadata when the inline parser runs and use this information
to check what was added within a cell. This avoids a lot of parsing for
each cell and substantially improves how quickly things run. However we
needed to hack the top level for loop to guarantee that we parse
markdown trees after all others. It's not the most elegant thing but
seems to do the job.
Since we are doing a good amount of contains range type logic I'm sure
there will be some errors, those will be good to add to unit tests
anyway, currently everything passes.
0 commit comments