mirror of
https://github.com/neovim/neovim.git
synced 2024-09-17 20:58:20 -04:00
4b02916334
Problem: `has-ancestor?` is O(n²) for the depth of the tree since it iterates over each of the node's ancestors (bottom-up), and each ancestor takes O(n) time. This happens because tree-sitter's nodes don't store their parent nodes, and the tree is searched (top-down) each time a new parent is requested. Solution: Make use of new `ts_node_child_containing_descendant()` in tree-sitter v0.22.6 (which is now the minimum required version) to rewrite the `has-ancestor?` predicate in C to become O(n). For a sample file, decreases the time taken by `has-ancestor?` from 360ms to 6ms. |
||
---|---|---|
.. | ||
api | ||
autocmd | ||
core | ||
editor | ||
ex_cmds | ||
fixtures | ||
legacy | ||
lua | ||
options | ||
plugin | ||
provider | ||
script | ||
shada | ||
terminal | ||
treesitter | ||
ui | ||
vimscript | ||
example_spec.lua | ||
preload.lua | ||
testnvim.lua |