Skip to content

feat(stdlib): bounded search (find_in/rfind_in/count_in) - #286

Merged
zaidejjo merged 4 commits into
devfrom
feat/bounded-search
Oct 7, 2026
Merged

zaidejjo merged 4 commits into
devfrom
feat/bounded-search

Conversation

@zaidejjo

@zaidejjo zaidejjo commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Follow-up to #282/#283: per-line use of unbounded search is O(n) per line, O(n²) per file (measured 3.5s vs 211ms on an 8MB tree). The bound must live in the primitive.

API (byte offsets, total functions, backend-identical)

  • str.find_in(s, sub, start, end) — first match in [start, end)
  • str.rfind_in(s, sub, start, end) — last match in [start, end)
  • str.count_in(s, sub, start, end) — non-overlapping matches in range
  • Empty patterns: find/rfind return clamped start, count returns 0
  • Sliceless byte windows (no boundary checks needed: valid patterns can't match mid-char, and no slicing means no panics on any input)

Layers

Rust natives (memchr) + checker sigs + C twins (memchr-skip) + headers + lowering + fixture cases + parity (existing entries) + docs.

Verify

  • e2e (VM) ✓, dual-engine parity (VM+AOT) ✓, stdlib lib ✓, clippy + fmt clean

@zaidejjo
zaidejjo merged commit 2828a29 into dev Oct 7, 2026
2 checks passed
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.

1 participant