mirror of
https://github.com/neovim/neovim.git
synced 2025-10-21 09:12:07 +00:00
Use weak tables in tree-sitter code (#17117)
feat(treesitter): use weak tables when possible Also add the defaulttable function to create a table whose values are created when a key is missing.
This commit is contained in:
@@ -140,12 +140,9 @@ function M.get_query(lang, query_name)
|
||||
end
|
||||
end
|
||||
|
||||
local query_cache = setmetatable({}, {
|
||||
__index = function(tbl, key)
|
||||
rawset(tbl, key, {})
|
||||
return rawget(tbl, key)
|
||||
end,
|
||||
})
|
||||
local query_cache = vim.defaulttable(function()
|
||||
return setmetatable({}, { __mode = 'v' })
|
||||
end)
|
||||
|
||||
--- Parse {query} as a string. (If the query is in a file, the caller
|
||||
--- should read the contents into a string before calling).
|
||||
|
Reference in New Issue
Block a user