oficina / mapa Public

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>
Paul Campbell pushed by paul@keymail.dev 3bc0714beb6c5d510ab6482b8bd3c74b47f6e175 parent 722f39a
7 files changed, +288 −71
  • editor/linear.test.mjs +37 −0
  • editor/markup.mjs +88 −25
  • internal/mapa/credits/assets.json +1 −1
  • internal/mapa/markup/scan.go +93 −0
  • internal/mapa/markup/scan_test.go +28 −0
  • internal/mapa/markup/spans.go +13 −21
  • internal/mapa/static/{editor.6d1c71633ba3db94.js => editor.950c9673b03506dd.js} +28 −24
editor/linear.test.mjs

Loading diff…

editor/markup.mjs

Loading diff…

internal/mapa/credits/assets.json

Loading diff…

internal/mapa/markup/scan.go

Loading diff…

internal/mapa/markup/scan_test.go

Loading diff…

internal/mapa/markup/spans.go

Loading diff…

internal/mapa/static/{editor.6d1c71633ba3db94.js => editor.950c9673b03506dd.js}

Loading diff…