diff options
| author | Martin Haug <mhaug@live.de> | 2021-05-26 23:36:03 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-05-26 23:50:40 +0200 |
| commit | 8e700606bb64c4ffda87cec333f7c76eae244911 (patch) | |
| tree | 8d0c40b04bc61cc3e3a9cad2f7b5f2eb4a691892 /src/cache.rs | |
| parent | e27f6c10146240a6c8b92930b27948083f08c9b5 (diff) | |
Add a cache for unchanged layouts
Co-Authored-By: Laurenz <laurmaedje@gmail.com>
Diffstat (limited to 'src/cache.rs')
| -rw-r--r-- | src/cache.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/cache.rs b/src/cache.rs new file mode 100644 index 00000000..4cf97ba6 --- /dev/null +++ b/src/cache.rs @@ -0,0 +1,34 @@ +//! Caching for incremental compilation. + +use std::collections::HashMap; + +use crate::layout::{Frame, Regions}; + +/// A cache for incremental compilation. +#[derive(Default, Debug, Clone)] +pub struct Cache { + /// A map that holds the layouted nodes from past compilations. + pub frames: HashMap<u64, FramesEntry>, +} + +impl Cache { + /// Create a new, empty cache. + pub fn new() -> Self { + Self::default() + } + + /// Clear the cache. + pub fn clear(&mut self) { + self.frames.clear(); + } +} + +/// Frames from past compilations and checks for their validity in future +/// compilations. +#[derive(Debug, Clone)] +pub struct FramesEntry { + /// The regions in which these frames are valid. + pub regions: Regions, + /// Cached frames for a node. + pub frames: Vec<Frame>, +} |
