Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/shape_run_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,27 @@ pub struct ShapeRunKey {
}

/// A helper structure for caching shape runs.
#[derive(Clone, Default)]
#[derive(Clone)]
pub struct ShapeRunCache {
age: u64,
cache: HashMap<ShapeRunKey, (u64, Vec<ShapeGlyph>)>,
age_registries: Vec<HashSet<ShapeRunKey>>,
}

impl Default for ShapeRunCache {
#[allow(clippy::vec_init_then_push)]
fn default() -> Self {
let mut age_registries = Vec::new();
age_registries.push(HashSet::default());

Self {
age: 0,
cache: Default::default(),
age_registries,
}
}
}

impl ShapeRunCache {
/// Get cache item, updating age if found
pub fn get(&mut self, key: &ShapeRunKey) -> Option<&Vec<ShapeGlyph>> {
Expand Down