Skip to content

fix: remove BranchDispatch, fix ExtractFirstBytes FoldCase (#166) - #172

Merged
kolkov merged 1 commit into
mainfrom
hotfix/issue-166-branch-dispatch
Oct 9, 2026
Merged

kolkov merged 1 commit into
mainfrom
hotfix/issue-166-branch-dispatch

Conversation

@kolkov

@kolkov kolkov commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #166. BranchDispatch removed (false negatives/positives on anchored alternations). ExtractFirstBytes: SimpleFold orbit + UTF-8 lead-bytes. See CHANGELOG for details.

BranchDispatch produced false negatives (^x(a|bc) on "xbc") and false
positives (^(GET|POST) / on "GET x") by ignoring prefix/suffix around
alternation and using "assume true" fallbacks for non-literal branches.

Removed entirely: lazy DFA and BoundedBacktracker already provide correct
O(1) first-byte dispatch inherently (as Rust regex does). Anchored
alternations now route to UseBoundedBacktracker with O(1) first-byte reject.
Performance: 13→66 ns short strings, still 1.5x faster than stdlib.

ExtractFirstBytes: added SimpleFold orbit for FoldCase literals and UTF-8
lead-byte handling for non-ASCII runes. Fixes ^[Vv] rejecting "v".

Closes #166
@kolkov
kolkov merged commit 709119d into main Oct 9, 2026
7 of 8 checks passed
@kolkov
kolkov deleted the hotfix/issue-166-branch-dispatch branch October 9, 2026 07:07
@codecov

codecov Bot commented Oct 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 46.93878% with 26 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
nfa/firstbytes.go 46.93% 26 Missing ⚠️

📢 Thoughts on this report? Let us know!

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

Benchmark Comparison

Comparing main → PR #172

Summary: geomean 79.75n 79.39n -0.44%

⚠️ Potential regressions detected:

geomean                               ³                +0.00%               ³
geomean                               ³                +0.00%               ³
geomean                         ³                +0.00%               ³
geomean                         ³                +0.00%               ³
AhoCorasickVsStdlib/coregex_IsMatch-4                   4.093µ ± ∞ ¹     4.122µ ± ∞ ¹     +0.71% (p=0.008 n=5)
AhoCorasickLargeInput/coregex_IsMatch_64KB-4            96.39µ ± ∞ ¹     97.36µ ± ∞ ¹     +1.01% (p=0.008 n=5)
AnchoredLiteralVsStdlib/coregex_short-4                 7.954n ± ∞ ¹     8.235n ± ∞ ¹     +3.53% (p=0.008 n=5)
AnchoredLiteralVsStdlib/stdlib_short-4                  263.5n ± ∞ ¹     265.8n ± ∞ ¹     +0.87% (p=0.008 n=5)
AnchoredLiteralVsStdlib/coregex_no_match-4              4.967n ± ∞ ¹     5.287n ± ∞ ¹     +6.44% (p=0.008 n=5)
ASCIIOptimization/WithoutASCII-4                        9.650n ± ∞ ¹     9.851n ± ∞ ¹     +2.08% (p=0.008 n=5)

Full results available in workflow artifacts. CI runners have ~10-20% variance.
For accurate benchmarks, run locally: ./scripts/bench.sh --compare

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

coregex.MustCompile(^x(a|bc)).MatchString("xbc") // false

1 participant