ReviewOS

home-lang/home

perf(markdown): make trailing-parenthesis autolink trimming linear

#741
Closed glennmichael123 opened this 11 days ago ·
11 days ago

Bun parity gap confirmed by the pathological autolink case in js/bun/md/md-edge-cases.test.ts.

Home recounts every opening and closing parenthesis over the entire candidate URL once for each trailing unmatched close parenthesis. A two-million-character suffix is therefore quadratic. Bun live Rust counts once, then decrements the close count while trimming the suffix, preserving the same GFM result in linear time.

Scope:

  • port Bun live single-pass parenthesis counting
  • retain balanced and one-extra-closing-parenthesis semantics
  • verify the original two-million-character corpus workload under the fixed memory guard

Parent: #66

11 days ago

Ported Bun's single-scan trailing-parenthesis accounting in 5212f81, removing the quadratic rescan while preserving the exact balance rule. Verified byte-for-behavior against Bun's live Rust source; Zig AST, formatter, and whitespace checks pass. Fresh native corpus acceptance remains pending under the fixed 3,840 MB safety ceiling.

Sign in to comment on this issue.