DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Batch: the compose cache keeps both halves of each number's bits on 32-bit targets
aiongg014363393033
diff --git a/crates/compose/src/cache.rs b/crates/compose/src/cache.rsindex 406f26aa4..f90006aba 100644--- a/crates/compose/src/cache.rs+++ b/crates/compose/src/cache.rs@@ -186,7 +186,7 @@ impl Cache {}// Advanced Type sizes super/subscripts.let a = doc.settings.advanced_type;- sig.extend([a.superscript_size, a.superscript_position, a.subscript_size, a.subscript_position].map(|v| v.to_bits() as usize));+ sig.extend([a.superscript_size, a.superscript_position, a.subscript_size, a.subscript_position].into_iter().flat_map(bits));// Missing glyphs: fallback fonts or the font's box.sig.push(usize::from(doc.settings.glyph_fallback));// Named lists continue from earlier stories.@@ -338,6 +338,13 @@ impl Cache {}}+/// Both halves of `v`'s bits: a 32-bit `usize` (wasm) would drop the high half, where whole+/// numbers keep their differences.+fn bits(v: f64) -> [usize; 2] {+ let b = v.to_bits();+ [(b & 0xffff_ffff) as usize, (b >> 32) as usize]+}+fn signature(doc: &Document, story: &Arc<Story>) -> (Vec<usize>, Vec<Arc<Item>>) {// The document's font scope: another document's fonts of the same name set it differently.// Sections name the pages under the frames (page-number and section markers).@@ -348,10 +355,9 @@ fn signature(doc: &Document, story: &Arc<Story>) -> (Vec<usize>, Vec<Arc<Item>>)Arc::as_ptr(&doc.styles) as usize,sections_hash(doc) as usize,doc.font_scope as usize,- g.start.to_bits() as usize,- g.increment.to_bits() as usize,usize::from(g.relative_to == designcraft_doc::GridRelative::TopMargin),];+ sig.extend([g.start, g.increment].into_iter().flat_map(bits));let mut keep = Vec::new();let mut spreads = Vec::new();for f in &story.frames {@@ -377,7 +383,7 @@ fn signature(doc: &Document, story: &Arc<Story>) -> (Vec<usize>, Vec<Arc<Item>>)// The page under a frame (found by x) gives its grid origin, page rect and side.for p in &sp.pages {let m = &p.margins;- sig.extend([p.x, p.width, p.height, m.top, m.bottom, m.inside, m.outside].map(|v| v.to_bits() as usize));+ sig.extend([p.x, p.width, p.height, m.top, m.bottom, m.inside, m.outside].into_iter().flat_map(bits));sig.push(p.side as usize);}for it in &sp.items {