diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2026-04-17 19:10:20 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-17 19:10:20 -0400 |
| commit | 0d4d285bd2c19697164175280b32bf93e3a7b1da (patch) | |
| tree | 0aa20f3e342279e9cba36e5c8daa0d38b2507c8d /test/functional/vimscript/eval_spec.lua | |
| parent | 03193e2963a6f9333afc3090ad2c8002b648fe11 (diff) | |
| download | rneovim-0d4d285bd2c19697164175280b32bf93e3a7b1da.tar.gz rneovim-0d4d285bd2c19697164175280b32bf93e3a7b1da.tar.bz2 rneovim-0d4d285bd2c19697164175280b32bf93e3a7b1da.zip | |
perf(vim.fn): call Lua-implemented vim.fn.xx() directly #39166
Problem:
- Builtin "Vimscript" functions (f_xx) are mostly implemented in C.
Partly that's because there is some boilerplate required to call out
to Lua.
- Calls to `vim.fn.foo()` always marshall over the Lua <=> Vimscript
("typval") bridge, even if `fn.foo()` is implemented entirely in Lua:
```
Lua => typval => Object => Lua => Object => typval => Lua.
```
Solution:
Functions declared in eval.lua with `func_lua` are implemented in
entirely in Lua (`_core/vimfn.lua`).
- `gen_eval.lua` wires `func_lua` entries to `lua_wrapper`, which handles
the typval conversion for Vimscript callers (slow path).
- `nlua_call()` detects `func_lua` functions and calls the Lua
implementation directly. This eliminates all conversion overhead for
Lua callers (fast path).
- Validate at build-time that `func`, `func_float`, and `func_lua` are
mutually exclusive.
- Migrate `hostname()` as a toy example, to show the idea.
Diffstat (limited to 'test/functional/vimscript/eval_spec.lua')
| -rw-r--r-- | test/functional/vimscript/eval_spec.lua | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/test/functional/vimscript/eval_spec.lua b/test/functional/vimscript/eval_spec.lua index 29f17fee19..b4e924104c 100644 --- a/test/functional/vimscript/eval_spec.lua +++ b/test/functional/vimscript/eval_spec.lua @@ -215,10 +215,10 @@ describe('listing functions using :function', function() command('let A = {-> 1}') local num = exec_capture('echo A'):match("function%('<lambda>(%d+)'%)") eq( - ([[ - function <lambda>%s(...) -1 return 1 - endfunction]]):format(num), + t.dedent([[ + function <lambda>%s(...) + 1 return 1 + endfunction]]):format(num), exec_capture(('function <lambda>%s'):format(num)) ) end) |