Skip to content

Commit

Permalink
chore: tiny optimization. (envoyproxy#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcchavezs authored Oct 16, 2022
1 parent d89933f commit fe41dea
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/ahocorasick/ahocorasick.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ func (ac Matcher) Matches(value string, n int) []string {
matchOffs := make([]uint32, 2*n)
matchOffsPtr := unsafe.Pointer(&matchOffs[0])
numMatches := matches(ac.ptr, unsafe.Pointer(sh.Data), uint32(sh.Len), uint32(n), matchOffsPtr)
var matches []string
var matches = make([]string, numMatches)
for i := 0; i < int(numMatches); i++ {
start := matchOffs[2*i]
end := matchOffs[2*i+1]
matches = append(matches, value[start:end])
matches[i] = value[start:end]
}
return matches
}

0 comments on commit fe41dea

Please sign in to comment.