From 9f489f591dbbe57d023f42f64a8a94524823c56f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Linse?= Date: Sat, 1 Jan 2022 16:41:16 +0100 Subject: [PATCH] perf(api): elide luaref copy when setting 'callback' in nvim_set_keymap --- src/nvim/api/private/helpers.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index 0c7ba1845c..4884a44cea 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -606,7 +606,8 @@ void modify_keymap(Buffer buffer, bool is_unmap, String mode, String lhs, String } if (opts != NULL && opts->callback.type == kObjectTypeLuaRef) { - lua_funcref = api_new_luaref(opts->callback.data.luaref); + lua_funcref = opts->callback.data.luaref; + opts->callback.data.luaref = LUA_NOREF; } MapArguments parsed_args = MAP_ARGUMENTS_INIT; if (opts) {