diff options
author | Mathias Fussenegger <f.mathias@zignar.net> | 2024-05-12 21:09:06 +0200 |
---|---|---|
committer | Lewis Russell <me@lewisr.dev> | 2024-05-14 09:42:42 +0100 |
commit | 2f4792943aa92223fadd472f20449cd13707ff7a (patch) | |
tree | 36433e284586f4182e2316b43bc60216e852b53a | |
parent | 8bb67d64e20d2e0d3e1892cb89d9bb8f558471e4 (diff) | |
download | rneovim-2f4792943aa92223fadd472f20449cd13707ff7a.tar.gz rneovim-2f4792943aa92223fadd472f20449cd13707ff7a.tar.bz2 rneovim-2f4792943aa92223fadd472f20449cd13707ff7a.zip |
perf(lsp): only joinpath for dirs in watchdirs
Doesn't have a huge impact, but showed up in profile output using
`require("jit.p").start("i1", "/tmp/profile")`
before:
31% joinpath
25% fs.lua:0
13% normalize
13% skip
8% _watchfunc
5% gsplit
3% spairs
after:
34% skip
29% fs.lua:0
12% joinpath
7% normalize
5% _watchfunc
5% spairs
-rw-r--r-- | runtime/lua/vim/_watch.lua | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/runtime/lua/vim/_watch.lua b/runtime/lua/vim/_watch.lua index 23c810099e..02b3f536c2 100644 --- a/runtime/lua/vim/_watch.lua +++ b/runtime/lua/vim/_watch.lua @@ -200,11 +200,13 @@ function M.watchdirs(path, opts, callback) local max_depth = 100 for name, type in vim.fs.dir(path, { depth = max_depth }) do - local filepath = vim.fs.joinpath(path, name) - if type == 'directory' and not skip(filepath, opts) then - local handle = assert(uv.new_fs_event()) - handles[filepath] = handle - handle:start(filepath, {}, create_on_change(filepath)) + if type == 'directory' then + local filepath = vim.fs.joinpath(path, name) + if not skip(filepath, opts) then + local handle = assert(uv.new_fs_event()) + handles[filepath] = handle + handle:start(filepath, {}, create_on_change(filepath)) + end end end |