Skip to content

feat(stdlib): positional str search (find/rfind/starts_with_at/ends_with_at/trim_span) - #282

Merged
zaidejjo merged 1 commit into
devfrom
feat/str-find
Oct 7, 2026
Merged

zaidejjo merged 1 commit into
devfrom
feat/str-find

Conversation

@zaidejjo

@zaidejjo zaidejjo commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Byte offsets throughout: O(1) per call, O(n) streaming total, backend-identical on every input (matches Rust str::find byte semantics; len()/slicing stay char-oriented by design, documented).

Layers (all five, in lockstep)

  • Rust natives (str_mod) + registry (natives/mod.rs, std + short spellings)
  • Checker sigs (funcs.rs) + registry count/self-test updates
  • C runtime twins (strings.c/.h) + AOT lowering map
  • e2e fixture str_find_test.zz + registration + dual-engine parity entry
  • docs/stdlib.md (signatures, offset contract, examples)

Notable decisions

  • Byte (not char) offsets: char conversion is O(from) per call, which makes streaming loops O(n²) (measured 16.7s vs 21ms on 322KB before the switch; 13ms after). Char slicing composition gap documented.
  • trim_span strips Unicode White_Space explicitly on both backends (never the host trim — sidesteps the native/VM trim split).
  • Non-boundary positions snap (ceil find, floor rfind/tail); empty patterns return clamped positions, never match in _at.

Verify

  • e2e (VM) ✓, dual-engine parity (VM+AOT) ✓, zz_stdlib 191/191 ✓, clippy + fmt clean
  • Streaming find-loop line scan beats split (13ms vs 21ms x5 on 322KB) with zero substrings allocated

…ith_at/trim_span)

Byte offsets throughout: O(1) per call, O(n) streaming total, and
backend-identical on every input (no char-counting divergence).
Matches Rust str::find/rfind byte semantics; len()/slicing stay
char-oriented by design (documented in stdlib.md).

Layers: Rust natives + checker sigs (std + short spellings),
C runtime twins + headers, AOT lowering map, e2e fixture +
dual-engine parity entry, stdlib docs. find-loop line scan beats
split on the 322KB bench (13ms vs 21ms x5) with zero substrings.
@zaidejjo
zaidejjo merged commit b258878 into dev Oct 7, 2026
1 of 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