From 3932bb2cb93be95d67fc56998423eb9ce047fdfa Mon Sep 17 00:00:00 2001 From: Laurenz Date: Mon, 9 Aug 2021 11:06:37 +0200 Subject: New source loading architecture --- src/layout/incremental.rs | 13 +++++-------- src/layout/mod.rs | 14 +++++++------- 2 files changed, 12 insertions(+), 15 deletions(-) (limited to 'src/layout') diff --git a/src/layout/incremental.rs b/src/layout/incremental.rs index 32353d6f..baf2991a 100644 --- a/src/layout/incremental.rs +++ b/src/layout/incremental.rs @@ -1,5 +1,5 @@ #[cfg(feature = "layout-cache")] -use std::collections::{hash_map::Entry, HashMap}; +use std::collections::HashMap; use std::ops::Deref; use super::*; @@ -68,13 +68,10 @@ impl LayoutCache { frames: Vec>>, level: usize, ) { - let entry = FramesEntry::new(frames, level); - match self.frames.entry(hash) { - Entry::Occupied(occupied) => occupied.into_mut().push(entry), - Entry::Vacant(vacant) => { - vacant.insert(vec![entry]); - } - } + self.frames + .entry(hash) + .or_default() + .push(FramesEntry::new(frames, level)); } /// Clear the cache. diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 56e0687a..246db714 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -29,9 +29,9 @@ use std::hash::Hash; use std::hash::Hasher; use std::rc::Rc; -use crate::font::FontCache; +use crate::font::FontStore; use crate::geom::*; -use crate::image::ImageCache; +use crate::image::ImageStore; use crate::util::OptionExt; use crate::Context; @@ -53,11 +53,11 @@ pub trait Layout { /// The context for layouting. pub struct LayoutContext<'a> { - /// The cache for parsed font faces. - pub fonts: &'a mut FontCache, - /// The cache for decoded imges. - pub images: &'a mut ImageCache, - /// The cache for layouting artifacts. + /// Stores parsed font faces. + pub fonts: &'a mut FontStore, + /// Stores decoded images. + pub images: &'a mut ImageStore, + /// Caches layouting artifacts. #[cfg(feature = "layout-cache")] pub layouts: &'a mut LayoutCache, /// How deeply nested the current layout tree position is. -- cgit v1.2.3