From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 25B8941D0BD for ; Thu, 17 Oct 2019 00:36:08 +0300 (MSK) Received: by mail-lj1-f193.google.com with SMTP id y23so249870lje.9 for ; Wed, 16 Oct 2019 14:36:08 -0700 (PDT) From: Cyrill Gorcunov Date: Thu, 17 Oct 2019 00:35:30 +0300 Message-Id: <20191016213531.1825-2-gorcunov@gmail.com> In-Reply-To: <20191016213531.1825-1-gorcunov@gmail.com> References: <20191016213531.1825-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 1/2] box/console: Move param handlers into file scope List-Id: Tarantool development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tml 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 --- 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