From 7b63b7c9d03b23f496ec9bfb8e91be3693b19a8f Mon Sep 17 00:00:00 2001 From: Charlie Stanton Date: Sun, 26 Feb 2023 09:37:30 +0000 Subject: Replace append with walk.ConcatData in many places to fix bug to do with semantics of append When doing append, be very careful as it does make changes in place to the underlying array of the slice which may affect other slices --- subex/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'subex/main.go') diff --git a/subex/main.go b/subex/main.go index e53a3c6..138de9a 100644 --- a/subex/main.go +++ b/subex/main.go @@ -66,7 +66,7 @@ type SubexBranch struct { func (pair SubexBranch) eat(char walk.Datum) []SubexBranch { states := pair.state.eat(pair.store, char) for i := range states { - states[i].output = append(pair.output, states[i].output...) + states[i].output = walk.ConcatData(pair.output, states[i].output) } return states } @@ -110,7 +110,7 @@ func RunTransducer(transducer SubexState, input <-chan walk.Datum) (output []wal for _, state := range states { outputEnds := state.accepting() for _, outputEnd := range outputEnds { - return append(state.output, outputEnd...), false + return walk.ConcatData(state.output, outputEnd), false } } return nil, true -- cgit v1.2.3