summaryrefslogtreecommitdiff
path: root/src/cache.rs
blob: 4cf97ba6fa30b7f6293d3bc0be6187ba3aed3482 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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>,
}