neovim/test/functional/treesitter
vanaigr 4b02916334
perf(treesitter): use child_containing_descendant() in has-ancestor? (#28512)
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.
2024-05-16 16:57:58 +02:00
..
fold_spec.lua test: improve test conventions 2024-04-23 18:17:04 +02:00
highlight_spec.lua fix(treesitter): enforce lowercase language names (#28546) 2024-04-28 16:27:47 +02:00
inspect_tree_spec.lua test: improve test conventions 2024-04-23 18:17:04 +02:00
language_spec.lua test: improve test conventions 2024-04-23 18:17:04 +02:00
node_spec.lua perf(treesitter): use child_containing_descendant() in has-ancestor? (#28512) 2024-05-16 16:57:58 +02:00
parser_spec.lua fix(treesitter): allow optional directive captures (#28664) 2024-05-14 09:14:43 -05:00
query_spec.lua perf(treesitter): use child_containing_descendant() in has-ancestor? (#28512) 2024-05-16 16:57:58 +02:00
utils_spec.lua test: improve test conventions 2024-04-23 18:17:04 +02:00