From f225dbe0717dba9c36043de0e2afe13e867dc1a2 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Wed, 11 Nov 2026 17:28:20 +0000 Subject: [PATCH] address review: the prune walk stops, and prunes nothing, once the page's form or byte allowance is spent --- crates/organize/src/prune.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/organize/src/prune.rs b/crates/organize/src/prune.rs index 3930277030..1a50e76331 100644 --- a/crates/organize/src/prune.rs +++ b/crates/organize/src/prune.rs @@ -256,10 +256,19 @@ impl Pruner<'_> { if !self.forms_seen.insert((r, inner_owner)) { return; } + // Each form entered uses the page's form allowance, and nothing more is read once either + // allowance is spent: what is left can't be told, so nothing of the file is pruned (as for a + // file nested too deep), rather than each remaining form being visited and its inherited + // dictionary cloned. + if self.budget.exhausted() || !self.budget.enter_form() { + self.too_deep = true; + return; + } #[cfg(test)] crate::work(1); match self.budget.decode_with_damage(self.doc, s, usize::MAX) { Ok((data, false)) => self.content(&data, &inner, inner_owner, depth + 1), + Err(_) if self.budget.exhausted() => self.too_deep = true, Ok((_, true)) | Err(_) => self.unread(&inner, inner_owner, depth + 1), } }