ReviewOS

home-lang/home

perf(markdown): memoize failed inline HTML terminator scans

#743
Closed glennmichael123 opened this 9 days ago ·
9 days ago

Port Bun’s HtmlScanMemo into Home. Unterminated comment, processing-instruction, declaration, and CDATA candidates currently rescan the remaining inline slice for every opener, producing quadratic behavior on valid adversarial input. The implementation must preserve Bun’s enclosing-slice/sub-slice address invariant, reset only at each top-level inline block, retain exact parsing semantics, and pass the pathological inline HTML corpus cases without input caps or truncation. Parent tracker: #66.

9 days ago

Implemented and pushed in 2d1d683. Home now memoizes failed comment/PI/declaration/CDATA terminator scans by enclosing slice address and length, translates contained label sub-slices safely, and resets the memo only at top-level inline-block boundaries. This preserves Bun's parsing semantics while eliminating repeated suffix scans. Zig AST, formatter, and whitespace gates pass; guarded native acceptance remains pending while another task owns the machine-wide heavy-run lock.

Sign in to comment on this issue.