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: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed
- **Dependency**: `github.com/coregx/ahocorasick` v0.2.1 → v0.3.0 — zero-allocation
`Find`/`FindAt` API (returns `(Match, bool)` instead of `*Match`)

### Planned
- Look-around assertions
- ARM NEON SIMD support (Go 1.26 `simd/archsimd` intrinsics — [#120](https://github.com/coregx/coregex/issues/120))
Expand Down
6 changes: 4 additions & 2 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ v0.12.20 ✅ → Premultiplied/tagged StateIDs, break-at-match DFA determinize,
v0.12.21 ✅ → Tagged start states, zero-alloc API (AllIndex iter.Seq),
1100x fewer mallocs, UseDFA for tiny NFA, -32% LangArena
v0.12.22 (Current) → Lazy memory architecture (Rust Cache model), 5-7x memory
reduction per pattern, WAF adoption unblocked (#158)
v0.12.22 ✅ → Lazy memory architecture (Rust Cache model), 5-7x memory
reduction per pattern, WAF adoption unblocked (#158)
v0.12.23 (Current) → ahocorasick v0.3.0 (zero-alloc Find/FindAt API)
v1.0.0-rc → Feature freeze, API locked
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module github.com/coregx/coregex
go 1.25.4

require (
github.com/coregx/ahocorasick v0.2.1
github.com/coregx/ahocorasick v0.3.0
golang.org/x/sys v0.40.0
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
github.com/coregx/ahocorasick v0.2.1 h1:JsZ5Rb32/SzGiGBl3vIwA8DAnY0+E6BLBhj+4HZsAbo=
github.com/coregx/ahocorasick v0.2.1/go.mod h1:SDcS9KTiwLP8FHNpYSO3Q3mRqrK8SYJAYpygrhcIils=
github.com/coregx/ahocorasick v0.3.0 h1:zKln33RykAkG9/eYh/trl85R6x1YChfEtrDQ3NADMsk=
github.com/coregx/ahocorasick v0.3.0/go.mod h1:SDcS9KTiwLP8FHNpYSO3Q3mRqrK8SYJAYpygrhcIils=
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
16 changes: 8 additions & 8 deletions meta/find.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,8 +590,8 @@ func (e *Engine) findTeddy(haystack []byte) *Match {
// Fat Teddy's AVX2 SIMD setup overhead exceeds benefit on small inputs.
if e.fatTeddyFallback != nil && len(haystack) < fatTeddySmallHaystackThreshold {
atomic.AddUint64(&e.stats.AhoCorasickSearches, 1)
match := e.fatTeddyFallback.Find(haystack, 0)
if match == nil {
match, found := e.fatTeddyFallback.Find(haystack, 0)
if !found {
return nil
}
return NewMatch(match.Start, match.End, haystack)
Expand Down Expand Up @@ -630,8 +630,8 @@ func (e *Engine) findTeddyAt(haystack []byte, at int) *Match {
// For Fat Teddy with small haystacks, use Aho-Corasick fallback.
if e.fatTeddyFallback != nil && len(haystack) < fatTeddySmallHaystackThreshold {
atomic.AddUint64(&e.stats.AhoCorasickSearches, 1)
match := e.fatTeddyFallback.FindAt(haystack, at)
if match == nil {
match, found := e.fatTeddyFallback.FindAt(haystack, at)
if !found {
return nil
}
return NewMatch(match.Start, match.End, haystack)
Expand Down Expand Up @@ -772,8 +772,8 @@ func (e *Engine) findAhoCorasick(haystack []byte) *Match {
}
atomic.AddUint64(&e.stats.AhoCorasickSearches, 1)

m := e.ahoCorasick.Find(haystack, 0)
if m == nil {
m, found := e.ahoCorasick.Find(haystack, 0)
if !found {
return nil
}
return NewMatch(m.Start, m.End, haystack)
Expand All @@ -786,8 +786,8 @@ func (e *Engine) findAhoCorasickAt(haystack []byte, at int) *Match {
}
atomic.AddUint64(&e.stats.AhoCorasickSearches, 1)

m := e.ahoCorasick.Find(haystack, at)
if m == nil {
m, found := e.ahoCorasick.Find(haystack, at)
if !found {
return nil
}
return NewMatch(m.Start, m.End, haystack)
Expand Down
8 changes: 4 additions & 4 deletions meta/find_indices.go
Original file line number Diff line number Diff line change
Expand Up @@ -1094,8 +1094,8 @@ func (e *Engine) findIndicesAhoCorasick(haystack []byte) (int, int, bool) {
}
atomic.AddUint64(&e.stats.AhoCorasickSearches, 1)

m := e.ahoCorasick.Find(haystack, 0)
if m == nil {
m, found := e.ahoCorasick.Find(haystack, 0)
if !found {
return -1, -1, false
}
return m.Start, m.End, true
Expand All @@ -1108,8 +1108,8 @@ func (e *Engine) findIndicesAhoCorasickAt(haystack []byte, at int) (int, int, bo
}
atomic.AddUint64(&e.stats.AhoCorasickSearches, 1)

m := e.ahoCorasick.Find(haystack, at)
if m == nil {
m, found := e.ahoCorasick.Find(haystack, at)
if !found {
return -1, -1, false
}
return m.Start, m.End, true
Expand Down
4 changes: 2 additions & 2 deletions prefilter/ahocorasick.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ func (p *AhoCorasickPrefilter) Find(haystack []byte, start int) int {
if start < 0 || start >= len(haystack) {
return -1
}
m := p.ac.Find(haystack, start)
if m == nil {
m, found := p.ac.Find(haystack, start)
if !found {
return -1
}
return m.Start
Expand Down
Loading