Each piece-table edit costs time linear in the buffer (piece lookup,
line-index update), so operations issuing one edit per match, line or
repetition were quadratic:
- Plain and regex replace-all build the new text in one pass and apply
it as one delete + one insert (one undo group, one chunked journal
record). 12 MB with 229k matches: minutes -> 0.14 s.
- Yank inserts the whole kill in one edit (it split and re-trimmed line
by line): 200k lines in 0.02 s.
- InsertText with a repeat count inserts the repeated text once; the
total is capped at 256 MiB (also across visual-line broadcast).
- Incremental regex search skips lines over 20,000 bytes and renderer
match highlighting over 10,000 (the previous change raised the render
limit to 1 MB): std::regex can be quadratic in line length even for
ordinary patterns such as '.*q', uninterruptibly, and these run on
every keystroke or frame. Explicit regex replace still processes all.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015rcVQiiWyTzoNrsvLSaAfB