Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ Regexes without extractable atoms are rejected at compile time. Use `CompileOpti

## Tools

The `cmd/` directory contains comparison and benchmarking tools that require [go-yara](https://github.com/hillu/go-yara) (cgo) to diff results against the reference YARA implementation.
The `cmd/` directory contains comparison and benchmarking tools. Comparisons against the reference YARA implementation require [go-yara](https://github.com/hillu/go-yara) (cgo).

- **corpus-bench** — benchmarks yargo vs go-yara scan speed over a file corpus
- **corpus-diff** — compares rule matches between yargo and go-yara across a file corpus
- **freq-gen** — generates byte frequency tables for atom scoring
- **parse-bench** — benchmarks rule parsing/compilation speed
- **parse-bench** — benchmarks rule parsing time and memory; add `-compile` to include scanner compilation
- **regex-bench** — benchmarks regex engine performance (go-re2, stdlib, coregex)

## Current Limitations
Expand Down
14 changes: 2 additions & 12 deletions ahocorasick/ahocorasick.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,7 @@ func (m *Match) Start() int {

type stateID uint32

const (
failedStateID stateID = 0
deadStateID stateID = 1
)
const failedStateID stateID = 0

func standardFindAt(a *iNFA, prestate *prefilterState, haystack []byte, at int, sID *stateID, dst *Match) bool {
return standardFindAtImp(a, prestate, a.prefil, haystack, at, sID, dst)
Expand Down Expand Up @@ -145,11 +142,8 @@ func standardFindAtImp(a *iNFA, prestate *prefilterState, pf *prefilter, haystac
}
at += 1

if sid == deadStateID || a.hasMatch(sid) {
if a.hasMatch(sid) {
*sID = sid
if sid == deadStateID {
return false
}
return a.getMatch(sid, 0, at, dst)
}
}
Expand All @@ -158,10 +152,6 @@ func standardFindAtImp(a *iNFA, prestate *prefilterState, pf *prefilter, haystac
}

func overlappingFindAt(a *iNFA, prestate *prefilterState, haystack []byte, at int, id *stateID, matchIndex *int, dst *Match) bool {
if a.anchored && at > 0 && *id == a.startID {
return false
}

// the bitset check keeps non-matching states out of the matches map
if a.hasMatch(*id) && *matchIndex < len(a.matches[*id]) {
ok := a.getMatch(*id, *matchIndex, at, dst)
Expand Down
Loading
Loading