diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-08-09 11:06:37 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-08-09 11:26:41 +0200 |
| commit | 3932bb2cb93be95d67fc56998423eb9ce047fdfa (patch) | |
| tree | c36bd4df1d2c74f8ae100d2f3bd3a0b232b797f5 /src/layout | |
| parent | 3c92bad9a7cd6b880de197806443ffcce2cac9d8 (diff) | |
New source loading architecture
Diffstat (limited to 'src/layout')
| -rw-r--r-- | src/layout/incremental.rs | 13 | ||||
| -rw-r--r-- | src/layout/mod.rs | 14 |
2 files changed, 12 insertions, 15 deletions
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<Constrained<Rc<Frame>>>, 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. |
