From c10bca852dfd2ed3ae8f776c12705675a8ab99bf Mon Sep 17 00:00:00 2001 From: Charlie Stanton Date: Mon, 24 Apr 2023 19:12:46 +0100 Subject: Adds a check to end subex execution early if no viable branches remain --- subex/main.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'subex') diff --git a/subex/main.go b/subex/main.go index ae829d9..c1718a4 100644 --- a/subex/main.go +++ b/subex/main.go @@ -112,6 +112,9 @@ func RunTransducer(transducer SubexState, input []walk.Atom) (output []walk.Atom newStates = append(newStates, state.eat(piece)...) } states = pruneStates(newStates) + if len(states) == 0 { + return nil, true + } } for _, state := range states { acceptingStacks := state.accepting() -- cgit v1.2.3