diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-05-29 11:13:58 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-05-29 11:14:07 -0700 |
| commit | e17822d1e548f96952efb95c64c69704fdfeaf76 (patch) | |
| tree | 209d604ac323c36453730bc354e2c7d8e467e121 /code_obj.lua | |
| parent | b6be516e3fbc082b1dbd9740b95185976f4b0040 (diff) | |
Cleaned up some asserts for performance.
Diffstat (limited to 'code_obj.lua')
| -rw-r--r-- | code_obj.lua | 13 |
1 files changed, 5 insertions, 8 deletions
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]*$") |
