pdfcraft/crates
Chiranjeevi U 9644aeb9e2
Cap unbounded editing and text caches; index form fields once (#1115)
* Cap editing and text-layer caches that grew without bound

The cos editing cache kept every touched object until save, so editing
a large document pinned its whole object graph. Bound it like the scan
reader: 1024 objects / 32 MB of owned bytes, 256 object streams /
32 MB, evicting to the newcomer. Returned objects outlive eviction, and
clones share the caches, so this only costs re-parsing.

The viewer text cache had the same shape: every visited page's text
stayed for the session. Retain visible, selected and matched pages plus
a 24-page prefetch window each frame; evicted pages re-extract on
revisit. Skipped while a search is active, where demand still wants
every page. Failures are never evicted: they cost nothing to remember.

cli info on a 1024-page/147 KB file (debug build, same host/command):
before 66.7 MB RSS, after 54.0 MB RSS (3 runs, tight).

Tests: editor count bound, byte bound, snapshot-clone reads (cos);
evict-far/keep-visible+matched+selection, search-active keep-all
(canvas). All mutation-checked: each bound goes red when disabled.

Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>

* Index form fields once per refresh instead of once per field

The form-scope refresh ran a linear find over all fields for every
field, O(F^2) on each keystroke; forms reach 10k fields. Build one
name index up front, O(F). entry().or_insert() keeps the old
first-match semantics for repeated field names.

New test with two same-named widgets pins first-wins and goes red
under insert. 141 engine tests green, clippy warnings and perf lints
clean.

Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>

---------

Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
2026-10-11 14:46:19 -04:00
..
a11y M9: stream structure-tree checks without a total-element cutoff (#926) 2026-10-11 12:31:35 -04:00
annot Comments: line breaks saved as CR show in comment text (#1113) 2026-10-11 14:46:05 -04:00
audit Add faux-redaction audit (paint-order and colour-aware, fail-closed) (#110) 2026-10-11 14:32:33 -04:00
automation Add faux-redaction audit (paint-order and colour-aware, fail-closed) (#110) 2026-10-11 14:32:33 -04:00
compare Rename PrintCraft to PdfCraft (#174) 2026-10-07 16:03:57 -04:00
content Fix #155: edit text across content stream pieces (#628) 2026-10-09 17:57:02 -04:00
cos Cap unbounded editing and text caches; index form fields once (#1115) 2026-10-11 14:46:19 -04:00
create M4, #569: Combine files takes images and text files (#1032) 2026-10-11 12:04:10 -04:00
crypt fix(crypt): R2–R4 passwords with non-ASCII characters open (PDFDocEncoding) (#905) 2026-10-10 17:10:39 -04:00
edit Add faux-redaction audit (paint-order and colour-aware, fail-closed) (#110) 2026-10-11 14:32:33 -04:00
engine Cap unbounded editing and text caches; index form fields once (#1115) 2026-10-11 14:46:19 -04:00
export Fix #526: keep text colour in Word, HTML and RTF export (#547) 2026-10-09 10:49:21 -04:00
filters Rename PrintCraft to PdfCraft (#174) 2026-10-07 16:03:57 -04:00
fonts Typed signatures draw Cyrillic and Greek letters (#846) (#963) 2026-10-11 13:20:11 -04:00
forms M14: Reuse form enumeration during document open (#1011) 2026-10-11 12:21:02 -04:00
geom M10: Enhance camera image finds the document's edges; rotate, crop or organize after Enhance page (part 3 of #1008) (#1027) 2026-10-11 12:31:23 -04:00
js M12: XFA script time limits start when the engine is ready (#1081) 2026-10-11 11:58:28 -04:00
measure M12: add deterministic snap property tests to the measure crate (#714) 2026-10-11 13:31:46 -04:00
model M2: pages with /UserUnit are shown at their size in points, as in Acrobat (#722) 2026-10-10 06:19:31 -04:00
ocr OCR: a scanned euro sign reads as €, not E (#796) 2026-10-10 15:08:04 -04:00
optimize M11: strip redundant ASCII stream wrappers during optimization (#989) 2026-10-11 13:21:20 -04:00
organize M10: stream Create Multiple sources without a fixed file-count cutoff (#978) 2026-10-11 13:20:58 -04:00
platform Linux: "Use system setting" asks the desktop, not winit (#881) 2026-10-10 15:47:33 -04:00
preflight PDF/A: no sRGB output intent for CMYK documents, and pdfa_verify checks the intent's colour space (#667) (#732) 2026-10-10 06:22:47 -04:00
print M10: Windows printing starts PowerShell by its full path (#1106) 2026-10-11 14:45:52 -04:00
redact fix(redact): the Email pattern finds internationalized addresses (#901) 2026-10-10 17:04:41 -04:00
render Comments: line breaks saved as CR show in comment text (#1113) 2026-10-11 14:46:05 -04:00
sign M9: visible digital signatures can show a drawn, typed or image graphic (#193) (#934) 2026-10-11 13:47:51 -04:00
ui-egui Cap unbounded editing and text caches; index form fields once (#1115) 2026-10-11 14:46:19 -04:00
xfa xfa, xfdf: refuse XML nested past 1024 levels instead of aborting the process (#987) 2026-10-11 13:38:10 -04:00
xfdf xfa, xfdf: refuse XML nested past 1024 levels instead of aborting the process (#987) 2026-10-11 13:38:10 -04:00