From 2460f0a7028550ea2d87492a4e8b95914fdba7b1 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Thu, 19 Aug 2021 16:45:04 +0200 Subject: perf(treesitter): avoid string lookup of highlight name in hot loop These numbers are guaranteed to be stable even if you do "highlight clear" (all attributes disappear, but not the id to name mapping itself) --- runtime/lua/vim/treesitter/highlighter.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'runtime/lua') diff --git a/runtime/lua/vim/treesitter/highlighter.lua b/runtime/lua/vim/treesitter/highlighter.lua index e003cf577a..bf5bd791c3 100644 --- a/runtime/lua/vim/treesitter/highlighter.lua +++ b/runtime/lua/vim/treesitter/highlighter.lua @@ -85,8 +85,10 @@ function TSHighlighterQuery.new(lang, query_string) hl = _link_default_highlight_once(lang .. hl, hl) end - rawset(table, capture, hl) - return hl + local id = a.nvim_get_hl_id_by_name(hl) + + rawset(table, capture, id) + return id end }) -- cgit