<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/subex/main.go
diff options
context:
space:
mode:
authorCharlie Stanton <charlie@shtanton.xyz>2023-02-26 09:37:30 +0000
committerCharlie Stanton <charlie@shtanton.xyz>2023-02-26 09:37:30 +0000
commit7b63b7c9d03b23f496ec9bfb8e91be3693b19a8f (patch)
tree824aa1c659e532537f812be36d0e0384eae1b2fd /subex/main.go
parent9ba3b1d97e8fd2a2e3c4bb08fe350c8dd5f9733e (diff)
downloadstred-go-7b63b7c9d03b23f496ec9bfb8e91be3693b19a8f.tar
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
Diffstat (limited to 'subex/main.go')
-rw-r--r--subex/main.go4
1 files changed, 2 insertions, 2 deletions
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