Markup: linear cleanBody and link scans, in the editor and in Go
Fable's final review of 58fd476, M6. cleanBody's /[ \t\n]+$/ tried every run of spaces to the end: 10 seconds over 80,000 of them. Each [ and [[ scanned for its ] or ]] to the line's end: seconds in the editor over a line of "[a", and Go's Spans, which every page view and the index run, took 70 seconds over the same 80,000 bytes. - cleanBody trims with a loop. - The link tests read per-text tables built in one pass on first use (Scan in markup.mjs, scan.go in Go), which answer exactly what the regexes and the ]] search answered: L4 holds the corpus unchanged. Gates: editor/linear.test.mjs and TestTheLinkScansAreLinear, 80,000 characters of each shape under 750ms. On the old code the Node cases take 5.4 to 41 seconds; the Go ones over a minute.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7 files changed,
+288
−71
editor/linear.test.mjs+37 −0editor/markup.mjs+88 −25internal/mapa/credits/assets.json+1 −1internal/mapa/markup/scan.go+93 −0internal/mapa/markup/scan_test.go+28 −0internal/mapa/markup/spans.go+13 −21internal/mapa/static/{editor.6d1c71633ba3db94.js => editor.950c9673b03506dd.js}+28 −24
editor/linear.test.mjsLoading diff…
editor/markup.mjsLoading diff…
internal/mapa/credits/assets.jsonLoading diff…
internal/mapa/markup/scan.goLoading diff…
internal/mapa/markup/scan_test.goLoading diff…
internal/mapa/markup/spans.goLoading diff…
internal/mapa/static/{editor.6d1c71633ba3db94.js => editor.950c9673b03506dd.js}Loading diff…