aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/generators
diff options
context:
space:
mode:
authorii14 <59243201+ii14@users.noreply.github.com>2023-04-27 19:25:08 +0200
committerGitHub <noreply@github.com>2023-04-27 19:25:08 +0200
commit1cb60405548e79f1ec63921540e1c3ebb3ddcc01 (patch)
treebf0706152d87cacb506868ccb8074381452f1410 /src/nvim/generators
parenteb4676c67f5dd54bcda473783315901a3444b40b (diff)
downloadrneovim-1cb60405548e79f1ec63921540e1c3ebb3ddcc01.tar.gz
rneovim-1cb60405548e79f1ec63921540e1c3ebb3ddcc01.tar.bz2
rneovim-1cb60405548e79f1ec63921540e1c3ebb3ddcc01.zip
perf(events): store autocommands in flat vectors (#23256)
Instead of nested linked lists, store autocommands in a flat, contiguous kvec_t, with one kvec_t per event type. Previously patterns were stored in each node of the outer linked list, so they can be matched only once on repeating patterns. They are now reference counted and referenced in each autocommand, and matching is skipped if the pattern repeats. Speeds up creation and deletion, execution is not affected. Co-authored-by: ii14 <ii14@users.noreply.github.com>
Diffstat (limited to 'src/nvim/generators')
-rw-r--r--src/nvim/generators/gen_events.lua19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/nvim/generators/gen_events.lua b/src/nvim/generators/gen_events.lua
index 27cec40b03..0eb231f012 100644
--- a/src/nvim/generators/gen_events.lua
+++ b/src/nvim/generators/gen_events.lua
@@ -35,27 +35,24 @@ names_tgt:write('\n {0, NULL, (event_T)0},')
enum_tgt:write('\n} event_T;\n')
names_tgt:write('\n};\n')
-local gen_autopat_events = function(name)
- names_tgt:write(string.format('\nstatic AutoPat *%s[NUM_EVENTS] = {\n ', name))
+do
+ names_tgt:write('\nstatic AutoCmdVec autocmds[NUM_EVENTS] = {\n ')
local line_len = 1
for _ = 1,((#events) - 1) do
- line_len = line_len + #(' NULL,')
+ line_len = line_len + #(' KV_INITIAL_VALUE,')
if line_len > 80 then
names_tgt:write('\n ')
- line_len = 1 + #(' NULL,')
+ line_len = 1 + #(' KV_INITIAL_VALUE,')
end
- names_tgt:write(' NULL,')
+ names_tgt:write(' KV_INITIAL_VALUE,')
end
- if line_len + #(' NULL') > 80 then
- names_tgt:write('\n NULL')
+ if line_len + #(' KV_INITIAL_VALUE') > 80 then
+ names_tgt:write('\n KV_INITIAL_VALUE')
else
- names_tgt:write(' NULL')
+ names_tgt:write(' KV_INITIAL_VALUE')
end
names_tgt:write('\n};\n')
end
-gen_autopat_events("first_autopat")
-gen_autopat_events("last_autopat")
-
enum_tgt:close()
names_tgt:close()