From 26bce7119200f37f8b9f3ddc1a2c76c85f7c88be Mon Sep 17 00:00:00 2001 From: Charlie Stanton Date: Fri, 21 Apr 2023 12:51:25 +0100 Subject: Changes the implementation of Atomise and Compound to no longer use goroutines This results in a massive performance boost, ~4x speedup --- main/command.go | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'main') diff --git a/main/command.go b/main/command.go index 9554f9d..136fb26 100644 --- a/main/command.go +++ b/main/command.go @@ -54,19 +54,12 @@ func (cmd DeletePathCommand) exec(state *ProgramState) { } func runSubex(state subex.SubexState, in []walk.WalkValue) (out []walk.WalkValue, error bool) { - valueStream := make(chan walk.WalkValue) - go func(in []walk.WalkValue, out chan<- walk.WalkValue) { - for _, value := range in { - out <- value - } - close(out) - }(in, valueStream) - atomStream := walk.Atomise(valueStream) - atomsOut, error := subex.RunTransducer(state, atomStream) + atomsIn := walk.Atomise(in) + atomsOut, error := subex.RunTransducer(state, atomsIn) if error { return nil, true } - valuesOut, err := walk.MemoryCompound(atomsOut) + valuesOut, err := walk.Compound(atomsOut) if err != nil { return nil, true } -- cgit v1.2.3