Minify only at new best program time

This commit is contained in:
Ian Gulliver
2021-11-23 20:34:10 -08:00
parent f0f28dbd51
commit 8a63bd3b3e
3 changed files with 19 additions and 19 deletions

View File

@@ -57,6 +57,15 @@ func (def *Definition) Grow(statusChan chan<- Status) (*vm.Program, error) {
}
if score > status.BestScore {
err = def.minifyProgram(prog)
if err != nil {
if statusChan != nil {
close(statusChan)
}
return nil, err
}
status.BestScore = score
status.BestProgram = prog.Copy()
@@ -65,20 +74,6 @@ func (def *Definition) Grow(statusChan chan<- Status) (*vm.Program, error) {
}
if status.BestScore == status.TargetScore {
err = def.minifyProgram(prog)
if err != nil {
if statusChan != nil {
close(statusChan)
}
return nil, err
}
status.BestProgram = prog.Copy()
if statusChan != nil {
statusChan <- status
}
if statusChan != nil {
close(statusChan)
}