mirror of
https://github.com/neovim/neovim
synced 2025-07-16 09:11:51 +00:00
refactor(treesitter): avoid unnecessarily copying tree
node:tree() now already copies the tree before returning it, for memory safety reasons.
This commit is contained in:
@ -979,8 +979,7 @@ function Query:iter_captures(node, source, start, stop, opts)
|
||||
|
||||
start, stop = value_or_node_range(start, stop, node)
|
||||
|
||||
-- Copy the tree to ensure it is valid during the entire lifetime of the iterator
|
||||
local tree = node:tree():copy()
|
||||
local tree = node:tree()
|
||||
local cursor = vim._create_ts_querycursor(node, self.query, start, stop, opts)
|
||||
|
||||
-- For faster checks that a match is not in the cache.
|
||||
@ -1079,8 +1078,7 @@ function Query:iter_matches(node, source, start, stop, opts)
|
||||
|
||||
start, stop = value_or_node_range(start, stop, node)
|
||||
|
||||
-- Copy the tree to ensure it is valid during the entire lifetime of the iterator
|
||||
local tree = node:tree():copy()
|
||||
local tree = node:tree()
|
||||
local cursor = vim._create_ts_querycursor(node, self.query, start, stop, opts)
|
||||
|
||||
local function iter()
|
||||
|
Reference in New Issue
Block a user