From e17822d1e548f96952efb95c64c69704fdfeaf76 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 29 May 2018 11:13:58 -0700 Subject: Cleaned up some asserts for performance. --- code_obj.lua | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'code_obj.lua') diff --git a/code_obj.lua b/code_obj.lua index e77af5c..990f3bc 100644 --- a/code_obj.lua +++ b/code_obj.lua @@ -15,10 +15,8 @@ Source = immutable({ if not start then start, stop = 1, #FILE_CACHE[filename] end - if stop then - assert(start <= stop + 1, "Invalid range: " .. tostring(start) .. ", " .. tostring(stop)) - else - error("HUH?") + if stop and start > stop + 1 then + error("Invalid range: " .. tostring(start) .. ", " .. tostring(stop)) end return filename, start, stop end, @@ -56,7 +54,9 @@ Source = immutable({ if type(self) == 'number' then offset, self = self, offset else - assert(type(offset) == 'number', "Cannot add Source and " .. tostring(type(offset))) + if type(offset) ~= 'number' then + error("Cannot add Source and " .. tostring(type(offset))) + end end return Source(self.filename, self.start + offset, self.stop) end, @@ -109,8 +109,6 @@ do local match = string.match for i = 1, n do local b = select(i, ...) - assert(b ~= self, "No recursion please.") - assert(not Source:is_instance(b)) bits[#bits + 1] = b if type(b) == 'string' then do @@ -136,7 +134,6 @@ do end self.current_indent = 0 for i, b in ipairs(bits) do - assert(b ~= self, "No recursion please.") if type(b) == 'string' then do local spaces = b:match("\n([ ]*)[^\n]*$") -- cgit v1.2.3