Skip to content

Box a big variant in CascadedValues to use less stack space

CascadedInner has two variants, and the second is a big struct:

#[allow(clippy::large_enum_variant)]
enum CascadedInner<'a> {
    FromNode(Ref<'a, Element>),
    FromValues(ComputedValues),
}

(Yes, clippy warned us...)

It turns out that deeply-nested elements can consume a lot of stack space, since every nested call to DrawingCtx::draw_from_use_node() will create a CascadedInner::FromValues - it is specifically to handle the independent cascading of nodes referenced from .

This commit just boxes the payload of that variant, so it should shrink the stack space of draw_from_use_node() by approximately 700 bytes.

Old size_of::<CascadedValues<'_>>() = 776 New size_of::<CascadedValues<'_>>() = 24 (plus the rest in the heap)

#686 (closed)

Merge request reports