Skip to content

Commit

Permalink
Finally remove deepcopy from main evaluation loop.
Browse files Browse the repository at this point in the history
  • Loading branch information
corywalker committed Jul 17, 2017
1 parent cc5acb4 commit cb2fee0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions expreduce/builtin_flowcontrol.go
Expand Up @@ -65,15 +65,15 @@ func GetFlowControlDefinitions() (defs []Definition) {
if len(this.Parts) != 3 {
return this
}
isequal := this.Parts[1].Eval(es).IsEqual(&Symbol{"True"}, &es.CASLogger)
isequal := this.Parts[1].DeepCopy().Eval(es).IsEqual(&Symbol{"True"}, &es.CASLogger)
cont := isequal == "EQUAL_TRUE"
for cont {
tmpRes := this.Parts[2].Eval(es)
tmpRes := this.Parts[2].DeepCopy().Eval(es)
retVal, isReturn := tryReturnValue(tmpRes)
if isReturn {
return retVal
}
isequal = this.Parts[1].Eval(es).IsEqual(&Symbol{"True"}, &es.CASLogger)
isequal = this.Parts[1].DeepCopy().Eval(es).IsEqual(&Symbol{"True"}, &es.CASLogger)
cont = isequal == "EQUAL_TRUE"
}

Expand Down
4 changes: 3 additions & 1 deletion expreduce/builtin_list.go
Expand Up @@ -163,7 +163,9 @@ func GetListDefinitions() (defs []Definition) {
toReturn := NewExpression([]Ex{&Symbol{"List"}})
for mis.cont() {
mis.defineCurrent(es)
toReturn.Parts = append(toReturn.Parts, this.Parts[1].Eval(es))
// TODO: use ReplacePD for this. We're only replacing
// symbols. Don't need a full Eval.
toReturn.Parts = append(toReturn.Parts, this.Parts[1].DeepCopy().Eval(es))
es.Debugf("%v\n", toReturn)
mis.next()
}
Expand Down
4 changes: 3 additions & 1 deletion expreduce/builtin_numbertheory.go
Expand Up @@ -39,7 +39,9 @@ func GetNumberTheoryDefinitions() (defs []Definition) {
}
r := asInt.Val.Cmp(zero)
if r > 0 {
ints = append(ints, asInt.Val)
tmpI := big.NewInt(0)
tmpI.Set(asInt.Val)
ints = append(ints, tmpI)
}
if r < 0 {
tmpI := big.NewInt(0)
Expand Down
2 changes: 1 addition & 1 deletion expreduce/ex_expression.go
Expand Up @@ -106,7 +106,7 @@ func (this *Expression) Eval(es *EvalState) Ex {
if currExHash == this.cachedHash {
return this
}
var currEx Ex = this.DeepCopy()
var currEx Ex = this
insideDefinition := false
for currExHash != lastExHash {
lastExHash = currExHash
Expand Down

0 comments on commit cb2fee0

Please sign in to comment.