From 3f3e4837d5f7d2d9cb1c89bd3a5b2ee8a730772a Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Wed, 16 Oct 2024 17:03:48 +0100 Subject: perf(validate): use lighter version - Also fix `vim.validate()` for PUC Lua when showing errors for values that aren't string or number. --- runtime/lua/vim/_editor.lua | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'runtime/lua/vim/_editor.lua') diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua index ce269f087d..f0b8cf6a52 100644 --- a/runtime/lua/vim/_editor.lua +++ b/runtime/lua/vim/_editor.lua @@ -473,9 +473,7 @@ do --- @param handle? false|integer --- @return vim.var_accessor local function make_dict_accessor(scope, handle) - validate({ - scope = { scope, 's' }, - }) + validate('scope', scope, 'string') local mt = {} function mt:__newindex(k, v) return vim._setvar(scope, handle or 0, k, v) @@ -1171,12 +1169,10 @@ function vim.deprecate(name, alternative, version, plugin, backtrace) local displayed = vim._truncated_echo_once(msg) return displayed and msg or nil else - vim.validate { - name = { name, 'string' }, - alternative = { alternative, 'string', true }, - version = { version, 'string', true }, - plugin = { plugin, 'string', true }, - } + vim.validate('name', name, 'string') + vim.validate('alternative', alternative, 'string', true) + vim.validate('version', version, 'string', true) + vim.validate('plugin', plugin, 'string', true) local msg = ('%s is deprecated'):format(name) msg = alternative and ('%s, use %s instead.'):format(msg, alternative) or (msg .. '.') -- cgit v1.3-3-g829e