aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/_meta/vimfn.lua
diff options
context:
space:
mode:
authorEvgeni Chasnovski <evgeni.chasnovski@gmail.com>2024-07-18 18:26:27 +0300
committerGitHub <noreply@github.com>2024-07-18 10:26:27 -0500
commitf61efe3fe77c9a517dccb9fd5ff7f16c0660ced4 (patch)
tree72dcf702742df872d28a50bad82434e590e30e73 /runtime/lua/vim/_meta/vimfn.lua
parentc69ea53c9d73a29f504043cc38d4e9fac076f93b (diff)
downloadrneovim-f61efe3fe77c9a517dccb9fd5ff7f16c0660ced4.tar.gz
rneovim-f61efe3fe77c9a517dccb9fd5ff7f16c0660ced4.tar.bz2
rneovim-f61efe3fe77c9a517dccb9fd5ff7f16c0660ced4.zip
perf(filetype): implement parent pattern pre-matching (#29660)
Problem: calling `vim.filetype.match()` has performance bottleneck in that it has to match a lot of Lua patterns against several versions of input file name. This might be the problem if users need to call it synchronously a lot of times. Solution: add "parent pattern pre-matching" which can be used to quickly reject several potential pattern matches at (usually rare) cost of adding time for one extra Lua pattern match. "Parent pattern" is a manually added/tracked grouping of filetype patterns which should have two properties: - Match at least the same set of strings as its filetype patterns. But not too much more. - Be fast to match. For them to be effective, group should consist from at least three filetype patterns. Example: for a filetpye pattern ".*/etc/a2ps/.*%.cfg", both "/etc/" and "%.cfg" are good parent patterns (prefer the one which can group more filetype patterns). After this commit, `vim.filetype.match()` on most inputs runs ~3.4 times faster (while some inputs may see less impact if they match many parent patterns).
Diffstat (limited to 'runtime/lua/vim/_meta/vimfn.lua')
0 files changed, 0 insertions, 0 deletions