From 7c9e006c8273a5305f50e020f3cd14c984cd7468 Mon Sep 17 00:00:00 2001 From: quincy-jc <184324679+quincy-jc@users.noreply.github.com> Date: Thu, 5 Nov 2026 17:31:51 +1100 Subject: [PATCH] perf(measure): read a page's operators one at a time for snapping Co-Authored-By: Claude Opus 5.5 --- crates/measure/src/snap.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/measure/src/snap.rs b/crates/measure/src/snap.rs index 95c1f2b08d..0f02c76250 100644 --- a/crates/measure/src/snap.rs +++ b/crates/measure/src/snap.rs @@ -1,6 +1,6 @@ //! Bounded path extraction and snapping in PDF user space, including nested Form XObjects. use crate::{Point, Result, check_points, distance, invalid}; -use pdfcraft_content::{Matrix, parse}; +use pdfcraft_content::Matrix; use pdfcraft_cos::{Dict, Document, ObjRef, Object}; use serde::Serialize; use std::collections::HashSet; @@ -336,7 +336,8 @@ impl Walker<'_> { let (x, y) = m.apply(x, y); [x, y] }; - for op in parse(data).ops { + // One at a time: a heavy page holds gigabytes as a list of operators. + for op in pdfcraft_content::ops(data) { if self.geometry.segs.len().saturating_add(path.segs.len()) >= self.limits.segments || self.geometry.targets().saturating_add(path.targets()) >= self.limits.targets {