make brackets more efficient

This commit is contained in:
2024-05-30 13:08:10 +01:00
parent 9945e1590f
commit 5afa0b10c7
2 changed files with 2 additions and 22 deletions

View File

@@ -6,18 +6,11 @@ import (
var bracketsCompile = makeRegex(`( *)\((.|\n)+\)( *)`) var bracketsCompile = makeRegex(`( *)\((.|\n)+\)( *)`)
type brackets struct {
VAL any
line int
code string
path string
}
func isBrackets(code UNPARSEcode) bool { func isBrackets(code UNPARSEcode) bool {
return bracketsCompile.MatchString(code.code) return bracketsCompile.MatchString(code.code)
} }
func parseBrackets(code UNPARSEcode, index int, codeline []UNPARSEcode) (brackets, bool, ArErr, int) { func parseBrackets(code UNPARSEcode, index int, codeline []UNPARSEcode) (any, bool, ArErr, int) {
trimmed := strings.TrimSpace(code.code) trimmed := strings.TrimSpace(code.code)
resp, worked, err, i := translateVal(UNPARSEcode{ resp, worked, err, i := translateVal(UNPARSEcode{
code: trimmed[1 : len(trimmed)-1], code: trimmed[1 : len(trimmed)-1],
@@ -25,10 +18,5 @@ func parseBrackets(code UNPARSEcode, index int, codeline []UNPARSEcode) (bracket
line: code.line, line: code.line,
path: code.path, path: code.path,
}, index, codeline, 0) }, index, codeline, 0)
return brackets{ return resp, worked, err, i
VAL: resp,
line: code.line,
code: code.realcode,
path: code.path,
}, worked, err, i
} }

View File

@@ -80,14 +80,6 @@ func runVal(line any, stack stack, stacklevel int) (any, ArErr) {
message: "cannot negate a non-number", message: "cannot negate a non-number",
EXISTS: true, EXISTS: true,
} }
case brackets:
if stackoverflow {
linenum = x.line
path = x.path
code = x.code
break
}
return runVal(x.VAL, stack, stacklevel+1)
case operationType: case operationType:
if stackoverflow { if stackoverflow {
linenum = x.line linenum = x.line