mirror of
https://github.com/storytold/wordcraft.git
synced 2026-11-08 03:32:19 +00:00
* docbin: a field's cached result keeps its formatting per run, not per character (#5477) The result was a Vec<(char, CharProps)>: 365 bytes per character, 1.44 GB at peak for a 4 MB file with one field. It is now a String plus a run list that gains an entry only when the formatting changes (25 MB peak for the same file). Output is unchanged. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * docbin: show the objects when the field-result test fails Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * docbin: resolve character formatting per run, not per character (#5478) The text loop looked up the piece four or five times and the CHPX once (a backward scan over up to 101 FKP entries) for every character, and cloned the memoised 368-byte CharProps each time. Now the walk keeps the piece span and the CHPX run of the previous character and reuses them while the next character is inside, and hands the memoised properties to the paragraph builder by reference: they are cloned when a run starts and not compared while the resolved formatting is unchanged. Output is identical, also on corrupt pages (a run's FC range is bounded by the smallest later start). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * docbin: tests for run ranges across bins, empty pieces and a whole read Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>