Closed l-kershaw closed 3 years ago
are files in neovim/runtime
meant to provide a stable api or is this moudle internal? it being undocumented makes me a bit skeptical of its use, anyways
i pushed a commit that locally scopes vim.F.if_nil
. conventional wisdom is that luajit doesn't cache table lookups so this
for i = 1, 100 do
vim.F.if_nil(nil,nil)
end
does 200 lookups and this
local if_nil = vim.F.if_nil
for i = 1, 100
if_nil(nil,nil)
end
does 2
@goolord thanks for merging 🙂
My understanding is that the vim.F
stuff is meant so that people don't have to rewrite the same functions everywhere.
It seems to be used both internally in neovim and in a range of plugins (see here).
I am not 100% confident on how LuaJIT responds to this sort of thing. My previous understanding was that it would handle this without a load of repeated lookups, but in any case your commit definitely won't hurt performance, so no problems here 👍
there is a section about this on page 3 of https://www.lua.org/gems/sample.pdf
There is an
if_nil
function built in to neovim already, so don't need to redefine one. (Defined here)