mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Remove hash() from AnyNode since caching is now fully transparent
This commit is contained in:
parent
b886ced408
commit
eabf28f081
@ -88,23 +88,18 @@ impl AnyNode {
|
|||||||
|
|
||||||
Self { node: Box::new(node), hash }
|
Self { node: Box::new(node), hash }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The cached hash for the boxed node.
|
|
||||||
pub fn hash(&self) -> u64 {
|
|
||||||
self.hash
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Layout for AnyNode {
|
impl Layout for AnyNode {
|
||||||
fn layout(&self, ctx: &mut LayoutContext, regions: &Regions) -> Vec<Frame> {
|
fn layout(&self, ctx: &mut LayoutContext, regions: &Regions) -> Vec<Frame> {
|
||||||
if let Some(hit) = ctx.cache.frames.get(&self.hash()) {
|
if let Some(hit) = ctx.cache.frames.get(&self.hash) {
|
||||||
if &hit.regions == regions {
|
if &hit.regions == regions {
|
||||||
return hit.frames.clone();
|
return hit.frames.clone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let frames = self.node.layout(ctx, regions);
|
let frames = self.node.layout(ctx, regions);
|
||||||
ctx.cache.frames.insert(self.hash(), FramesEntry {
|
ctx.cache.frames.insert(self.hash, FramesEntry {
|
||||||
regions: regions.clone(),
|
regions: regions.clone(),
|
||||||
frames: frames.clone(),
|
frames: frames.clone(),
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user