From 7410e42bc00c8438884a475ccf8a9e07b73eaec3 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 14 May 2018 14:45:38 -0700 Subject: Minor optimizations. --- nomsu.lua | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'nomsu.lua') diff --git a/nomsu.lua b/nomsu.lua index 9860772..472846a 100644 --- a/nomsu.lua +++ b/nomsu.lua @@ -131,12 +131,14 @@ do return self .. stringify(other) end STRING_METATABLE.__index = function(self, i) + local ret = string[i] + if ret ~= nil then + return ret + end if type(i) == 'number' then return string.sub(self, i, i) elseif type(i) == 'table' then return string.sub(self, i[1], i[2]) - else - return string[i] end end end @@ -1103,12 +1105,14 @@ OPTIONS print_err_msg(error_message) return os.exit(false, true) end - local ldt - ok, ldt = pcall(require, 'ldt') - if ok then - ldt.guard(run) - else - xpcall(run, err_hand) + do + local ldt + ok, ldt = pcall(require, 'ldt') + if ok then + ldt.guard(run) + else + xpcall(run, err_hand) + end end end return NomsuCompiler -- cgit v1.2.3