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.moon | |
| parent | b6be516e3fbc082b1dbd9740b95185976f4b0040 (diff) | |
Cleaned up some asserts for performance.
Diffstat (limited to 'code_obj.moon')
| -rw-r--r-- | code_obj.moon | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/code_obj.moon b/code_obj.moon index d764430..e821b7e 100644 --- a/code_obj.moon +++ b/code_obj.moon @@ -8,8 +8,7 @@ Source = immutable {"filename","start","stop"}, { __new: (filename, start, stop)=> if not start start, stop = 1, #FILE_CACHE[filename] - if stop then assert(start <= stop+1, "Invalid range: #{start}, #{stop}") - else error("HUH?") + if stop and start > stop+1 then error("Invalid range: #{start}, #{stop}") return filename, start, stop from_string: (str)=> filename,start,stop = str\match("^(.-)%[(%d+):(%d+)%]$") @@ -34,7 +33,7 @@ Source = immutable {"filename","start","stop"}, { __add: (offset)=> if type(self) == 'number' offset, self = self, offset - else assert(type(offset) == 'number', "Cannot add Source and #{type(offset)}") + else if type(offset) != 'number' then error("Cannot add Source and #{type(offset)}") return Source(@filename, @start+offset, @stop) sub: (start, stop)=> start or= 1 @@ -80,8 +79,6 @@ class Code match = string.match for i=1,n b = select(i, ...) - assert(b != self, "No recursion please.") - assert(not Source\is_instance(b)) bits[#bits+1] = b if type(b) == 'string' if spaces = match(b, "\n([ ]*)[^\n]*$") @@ -99,7 +96,6 @@ class Code bits[i] = select(i, ...) @current_indent = 0 for i,b in ipairs(bits) - assert(b != self, "No recursion please.") if type(b) == 'string' if spaces = b\match("\n([ ]*)[^\n]*$") @current_indent = #spaces |
