Skip to main content

NodeCache

Struct NodeCache 

Source
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: bool

Fast check for dirty propagation (Taffy optimization). When true, all slots are empty — ancestors are also dirty.

Implementations§

Source§

impl NodeCache

Source

pub fn clear(&mut self)

Clear all cache entries, marking this node as dirty.

Source

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.

Source

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.

Source

pub fn store_size(&mut self, slot: usize, entry: SizingCacheEntry)

Store a sizing result in the given slot.

Source

pub fn get_layout(&self, known_dims: LogicalSize) -> Option<&LayoutCacheEntry>

Look up the full layout cache entry.

Source

pub fn store_layout(&mut self, entry: LayoutCacheEntry)

Store a full layout result.

Trait Implementations§

Source§

impl Clone for NodeCache

Source§

fn clone(&self) -> NodeCache

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NodeCache

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for NodeCache

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool