pub struct SelectorMatchCache { /* private fields */ }Expand description
Memoizes selector match results for one DOM/rule-set epoch.
Implementations§
Source§impl SelectorMatchCache
impl SelectorMatchCache
pub fn new() -> Self
pub fn with_capacity(capacity: usize) -> Self
Sourcepub fn get_or_insert(
&mut self,
selector: &Arc<ComplexSelector>,
node_id: NodeId,
compute: impl FnOnce() -> bool,
) -> bool
pub fn get_or_insert( &mut self, selector: &Arc<ComplexSelector>, node_id: NodeId, compute: impl FnOnce() -> bool, ) -> bool
Returns the cached match result for selector against node_id,
computing and storing it with compute on a miss.
Entries from a previous epoch are treated as misses: they are never returned, even if they happen to still be in the map.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Drops every entry and bumps the epoch. Call when the DOM snapshot or the rule set changes.
After this call, all previously cached results are stale: [get_or_insert]
will treat them as misses because their epoch no longer matches.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn capacity(&self) -> usize
pub fn stats(&self) -> CacheStatsSnapshot
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for SelectorMatchCache
impl RefUnwindSafe for SelectorMatchCache
impl Send for SelectorMatchCache
impl Sync for SelectorMatchCache
impl Unpin for SelectorMatchCache
impl UnsafeUnpin for SelectorMatchCache
impl UnwindSafe for SelectorMatchCache
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
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> ⓘ
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 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> ⓘ
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§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().