Type Alias style::sharing::SharingCache

source ·
type SharingCache<E> = SharingCacheBase<StyleSharingCandidate<E>>;
Expand description

Style sharing caches are are large allocations, so we store them in thread-local storage such that they can be reused across style traversals. Ideally, we’d just stack-allocate these buffers with uninitialized memory, but right now rustc can’t avoid memmoving the entire cache during setup, which gets very expensive. See issues like [1] and [2].

Given that the cache stores entries of type TElement, we transmute to usize before storing in TLS. This is safe as long as we make sure to empty the cache before we let it go.

[1] https://github.com/rust-lang/rust/issues/42763 [2] https://github.com/rust-lang/rust/issues/13707

Aliased Type§

struct SharingCache<E> {
    entries: LRUCache<StyleSharingCandidate<E>, 32>,
}

Fields§

§entries: LRUCache<StyleSharingCandidate<E>, 32>

Implementations§

source§

impl<Candidate> SharingCacheBase<Candidate>

source

fn clear(&mut self)

source

fn is_empty(&self) -> bool

source§

impl<E: TElement> SharingCacheBase<StyleSharingCandidate<E>>

source

fn insert( &mut self, element: E, validation_data_holder: Option<&mut StyleSharingTarget<E>> )

Trait Implementations§

source§

impl<Candidate> Default for SharingCacheBase<Candidate>

source§

fn default() -> Self

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