pub struct MemoizedSubView<'a> { /* private fields */ }Expand description
A SubView that remembers what each proposal measured.
Containers probe the same child repeatedly — size_that_fits measures at the
ideal proposal, place measures again at the resolved bounds, alignment-guide
resolution measures once more per guide — and a container that is itself a child
re-runs all of that for its own parent’s probes, so the repeats multiply with
tree depth. Wrapping each child for the duration of one pass collapses them to
one measure per distinct proposal.
The cache is a fixed-capacity inline array, scanned linearly: a pass probes any
one child a handful of times, and keeping it inline means wrapping a child costs
no allocation — which matters on the embedded backend, whose budget is heap
traffic per frame rather than CPU. A child probed at more than
MEMOIZED_PROPOSALS distinct proposals simply measures again for the extras.
Entries are keyed on the proposal’s bits, so -0.0 and a NaN proposal compare
consistently instead of by float equality.
Implementations§
Source§impl<'a> MemoizedSubView<'a>
impl<'a> MemoizedSubView<'a>
Sourcepub fn new(inner: &'a dyn SubView) -> MemoizedSubView<'a>
pub fn new(inner: &'a dyn SubView) -> MemoizedSubView<'a>
Wraps inner with a cache that lives as long as this value.