Made zeroLengthMatchState() return a pointer; reduced the number of comparisons performd by nfaState.equals

implementPCREMatchingRules
Aadhavan Srinivasan 4 weeks ago
parent 99230b49de
commit 62ca1a872a

@ -402,19 +402,20 @@ func newState() nfaState {
}
// Creates and returns a state that _always_ has a zero-length match.
func zeroLengthMatchState() nfaState {
start := newState()
func zeroLengthMatchState() *nfaState {
start := &nfaState{}
start.content = newContents(epsilon)
start.isEmpty = true
start.assert = alwaysTrueAssert
start.output = append([]*nfaState{}, start)
return start
}
func (s nfaState) equals(other nfaState) bool {
return slices.Equal(s.content, other.content) &&
s.isEmpty == other.isEmpty &&
return s.isEmpty == other.isEmpty &&
s.isLast == other.isLast &&
slices.Equal(s.output, other.output) &&
slices.Equal(s.content, other.content) &&
s.next == other.next &&
s.isKleene == other.isKleene &&
s.isQuestion == other.isQuestion &&

Loading…
Cancel
Save