From: Cyrill Gorcunov <gorcunov@gmail.com>
To: tml <tarantool-patches@dev.tarantool.org>
Subject: [Tarantool-patches] [PATCH 1/2] box/console: Move param handlers into file scope
Date: Thu, 17 Oct 2019 00:35:30 +0300 [thread overview]
Message-ID: <20191016213531.1825-2-gorcunov@gmail.com> (raw)
In-Reply-To: <20191016213531.1825-1-gorcunov@gmail.com>
This will allow us to reuse this map in other routines
and same time optimize memory allocation a bit.
Part-of #4568
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
src/box/lua/console.lua | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/src/box/lua/console.lua b/src/box/lua/console.lua
index 6a0133648..e1941f85d 100644
--- a/src/box/lua/console.lua
+++ b/src/box/lua/console.lua
@@ -256,24 +256,25 @@ local function set_output(storage, value)
return true
end
+local param_handlers = {
+ language = set_language,
+ lang = set_language,
+ l = set_language,
+ output = set_output,
+ o = set_output,
+ delimiter = set_delimiter,
+ delim = set_delimiter,
+ d = set_delimiter
+}
+
local function set_param(storage, func, param, value)
- local params = {
- language = set_language,
- lang = set_language,
- l = set_language,
- output = set_output,
- o = set_output,
- delimiter = set_delimiter,
- delim = set_delimiter,
- d = set_delimiter
- }
if param == nil then
return format(false, 'Invalid set syntax, type \\help for help')
end
- if params[param] == nil then
+ if param_handlers[param] == nil then
return format(false, 'Unknown parameter: ' .. tostring(param))
end
- return format(pcall(params[param], storage, value))
+ return format(pcall(param_handlers[param], storage, value))
end
local function help_wrapper(storage)
--
2.20.1
next prev parent reply other threads:[~2019-10-16 21:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-16 21:35 [Tarantool-patches] [PATCH 0/2] box/console: Fix hang on remote console enter Cyrill Gorcunov
2019-10-16 21:35 ` Cyrill Gorcunov [this message]
2019-10-16 21:35 ` [Tarantool-patches] [PATCH 2/2] box/console: Test for exact command before setting eos Cyrill Gorcunov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191016213531.1825-2-gorcunov@gmail.com \
--to=gorcunov@gmail.com \
--cc=tarantool-patches@dev.tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH 1/2] box/console: Move param handlers into file scope' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox