From 8e325fa33ef516fe43b29d2d377f8c4839188acb Mon Sep 17 00:00:00 2001 From: Ghoulboy Date: Fri, 12 Mar 2021 16:35:53 +0100 Subject: [PATCH] compact config code cos it's easy, and reduces a function call, making it like 2 microticks faster, but thats what tmc is for isnt it... --- waypoint.sc | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/waypoint.sc b/waypoint.sc index 732db78..e597026 100644 --- a/waypoint.sc +++ b/waypoint.sc @@ -123,25 +123,20 @@ _error(msg)->( exit() ); -_get_commands() -> ( - base_commands = { - '' -> 'help', - 'del ' -> 'del', - 'add ' -> ['add', null, null], - 'add ' -> ['add', null], - 'add ' -> 'add', - 'edit ' -> 'edit', - 'list' -> ['list', null], - 'list ' -> 'list', - }; - if(_is_tp_allowed(), put(base_commands, 'tp ', 'tp')); - base_commands; -); - __config() -> { 'scope'->'global', 'stay_loaded'-> true, - 'commands' -> _get_commands(), + 'commands' -> { + if(_is_tp_allowed(), 'tp ' -> 'tp', null), //if it's not allowed, then the ''->'' will be overwritten by next line + '' -> 'help', + 'del ' -> 'del', + 'add ' -> ['add', null, null], + 'add ' -> ['add', null], + 'add ' -> 'add', + 'edit ' -> 'edit', + 'list' -> ['list', null], + 'list ' -> 'list', + }, 'arguments' -> { 'waypoint' -> { 'type' -> 'term',