From 8534174ea1d83d3d8a7ed9e8e837cd075daaa5e0 Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Thu, 6 Feb 2025 22:06:22 -0500 Subject: [PATCH] Use pointers instead of values --- regex/compile.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/regex/compile.go b/regex/compile.go index 0429c37..fa51e0d 100644 --- a/regex/compile.go +++ b/regex/compile.go @@ -987,7 +987,8 @@ func thompson(re []postfixNode) (Reg, error) { if c.nodetype == charclassNode { // A Character class consists of all the nodes in it, alternated // Map the list of nodes to a list of states, each state containing the contents of a specific node states := funcMap(c.nodeContents, func(node postfixNode) *nfaState { - s := newState() + s := &nfaState{} + s.output = append(s.output, s) nodeContents := node.contents if caseInsensitive { nodeContents = slices.Concat(funcMap(nodeContents, func(r rune) []rune { @@ -1001,7 +1002,7 @@ func thompson(re []postfixNode) (Reg, error) { return n.contents })...) } - return &s + return s }) // Reduce the list of states down to a single state by alternating them toAdd := funcReduce(states, func(s1 *nfaState, s2 *nfaState) *nfaState {