From 7ad81f944fb521e9bf46112d17e6903ac71cdfa7 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 3 Nov 2026 22:32:17 +0000 Subject: [PATCH] address review: size text cost by the Paragraph and Run struct sizes --- crates/engine/src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index 54866374a..65fec507a 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -811,9 +811,11 @@ fn clamp_selection(st: &mut DocState) { /// Default for [`History::byte_limit`]. pub const UNDO_BYTE_BUDGET: usize = 256 << 20; -/// A rough size of a text body in memory: its paragraphs and runs. +/// A rough size of a text body in memory: its paragraphs and runs, at their inline struct sizes. fn text_cost(t: &deckcraft_model::text::TextBody) -> usize { - t.paragraphs.iter().map(|p| 96 + p.runs.iter().map(|r| 128 + r.text.len()).sum::()).sum() + use deckcraft_model::text::{Paragraph, Run}; + let (para, run) = (std::mem::size_of::(), std::mem::size_of::()); + t.paragraphs.iter().map(|p| para + p.runs.iter().map(|r| run + r.text.len()).sum::()).sum() } /// A rough size of comments in memory, replies included.