mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +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)
|
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()
|
||||||
local tree = node:tree():copy()
|
|
||||||
local cursor = vim._create_ts_querycursor(node, self.query, start, stop, opts)
|
local cursor = vim._create_ts_querycursor(node, self.query, start, stop, opts)
|
||||||
|
|
||||||
-- For faster checks that a match is not in the cache.
|
-- 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)
|
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()
|
||||||
local tree = node:tree():copy()
|
|
||||||
local cursor = vim._create_ts_querycursor(node, self.query, start, stop, opts)
|
local cursor = vim._create_ts_querycursor(node, self.query, start, stop, opts)
|
||||||
|
|
||||||
local function iter()
|
local function iter()
|
||||||
|
Reference in New Issue
Block a user