#652

Use capture-free RE2JS API for boolean regex tests

Draftasafyishwants to merge intofrom

UserRegex.test() currently calls Matcher.find(), which requests group-zero positions and forces RE2JS's NFA path even though the caller only needs a boolean. Call the existing capture-free RE2JS.test() API so these searches can use the dependency's DFA, preserving the wrapper's current lastIndex behavior and leaving capture/position consumers unchanged.

A local RE2JS 1.3.3 comparison of 100,000 identical negative matches took 2,042ms through the reused matcher versus 45ms through test(). In our downstream fork, the corresponding 106MB rg -n -i search took 20.33s before and 0.90s after, with identical output and exit status. This changes no regex dependency or engine.

Validation on the latest head: 156 regex/search-engine tests, TypeScript and scoped Biome checks pass. Differential cases cover the observed alternation/repetition pattern, Unicode folds and malformed surrogates, flags, anchors, word and non-word boundaries, empty matches, and interleaved boolean/capture operations. The boundary cases previously tested only in the combined downstream runtime are now included here.

Activity

4
vercel[bot]10d ago

@asafyish is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

auto-maintain[bot]10d ago

🤖 auto-maintain review

Automated, advisory triage for @asafyish's PR. Facts below are read from the GitHub API.

CheckResult
Author's merged PRs (this repo)1
Account established✅ (age 5392d · 13 followers · 7 public repos)
Commits signed/verified⚠️ 0/2
Changeset included✅ (.changeset/salty-parts-smile.md)

Review panel: 🟢 low highest severity

just-bash maintainer code review: 🟢 low

No actionable correctness or maintainability issues found in the complete diff.

General code review: 🟢 low

No actionable defects found in the complete base-to-head diff.

Adversarial security: 🟢 low

No actionable adversarial security findings in the complete diff.

Adversarial security (second opinion): 🟢 low

The diff only swaps UserRegex.test()'s internal RE2JS call from a reused Matcher.find() to the capture-free test() on the same compiled pattern, plus a changeset and differential tests; lastIndex semantics, the shared-matcher invariants used by exec/search/replace/matchAll, and all limit/abort handling are unchanged, and there are no dependency, build, CI, network, filesystem, or process-execution changes — no security-relevant findings.

Standard Bash and host portability: 🟢 low

No Bash or host-portability issues found in the complete diff.

Posted by auto-maintain. This automated code review is advisory; a human maintainer makes the call.

This pull request is a draft

Merging is unavailable until it is marked ready for review.