pub struct NodeCache {
pub measure_entries: [Option<SizingCacheEntry>; 9],
pub layout_entry: Option<LayoutCacheEntry>,
pub is_empty: bool,
}Expand description
Per-node cache entry with 9 measurement slots + 1 full layout slot.
Inspired by Taffy’s Cache struct (9+1 slots per node). The deterministic
slot index is computed from the constraint combination, so entries never
clobber each other (unlike the old global BTreeMap where fixed-point
collisions were possible).
NOT stored on LayoutNode — lives in the external LayoutCacheMap.
Fields§
§measure_entries: [Option<SizingCacheEntry>; 9]9 measurement slots (Taffy’s deterministic scheme):
- Slot 0: both dimensions known
- Slots 1-2: only width known (MaxContent/Definite vs MinContent)
- Slots 3-4: only height known (MaxContent/Definite vs MinContent)
- Slots 5-8: neither known (2×2 combos of width/height constraint types)
layout_entry: Option<LayoutCacheEntry>1 full layout slot (with child positions, overflow, baseline). Only populated after PerformLayout, not after ComputeSize.
is_empty: boolFast check for dirty propagation (Taffy optimization). When true, all slots are empty — ancestors are also dirty.
Implementations§
Source§impl NodeCache
impl NodeCache
Sourcepub fn slot_index(
width_known: bool,
height_known: bool,
width_type: AvailableWidthType,
height_type: AvailableWidthType,
) -> usize
pub fn slot_index( width_known: bool, height_known: bool, width_type: AvailableWidthType, height_type: AvailableWidthType, ) -> usize
Compute the deterministic slot index from constraint dimensions.
This is Taffy’s slot selection scheme: given whether width/height are “known” (definite constraint provided by parent) and what type of constraint applies to the unknown dimension(s), we get a unique slot 0–8.
Sourcepub fn get_size(
&self,
slot: usize,
known_dims: LogicalSize,
) -> Option<&SizingCacheEntry>
pub fn get_size( &self, slot: usize, known_dims: LogicalSize, ) -> Option<&SizingCacheEntry>
Look up a sizing cache entry, implementing Taffy’s “result matches request” optimization: if the caller provides the result size as a known dimension (common in Pass1→Pass2 transitions), it’s still a cache hit.
Sourcepub fn store_size(&mut self, slot: usize, entry: SizingCacheEntry)
pub fn store_size(&mut self, slot: usize, entry: SizingCacheEntry)
Store a sizing result in the given slot.
Sourcepub fn get_layout(&self, known_dims: LogicalSize) -> Option<&LayoutCacheEntry>
pub fn get_layout(&self, known_dims: LogicalSize) -> Option<&LayoutCacheEntry>
Look up the full layout cache entry.
Sourcepub fn store_layout(&mut self, entry: LayoutCacheEntry)
pub fn store_layout(&mut self, entry: LayoutCacheEntry)
Store a full layout result.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NodeCache
impl RefUnwindSafe for NodeCache
impl Send for NodeCache
impl Sync for NodeCache
impl Unpin for NodeCache
impl UnsafeUnpin for NodeCache
impl UnwindSafe for NodeCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more