Shorten the naming around the style sharing cache.

MozReview-Commit-ID: EcVQDLoxwFP
This commit is contained in:
Bobby Holley 2017-09-07 15:06:57 -07:00
parent 6623b1f80d
commit db67cd1759
3 changed files with 11 additions and 11 deletions

View file

@ -26,7 +26,7 @@ use selectors::matching::ElementSelectorFlags;
use servo_arc::Arc; use servo_arc::Arc;
#[cfg(feature = "servo")] use servo_atoms::Atom; #[cfg(feature = "servo")] use servo_atoms::Atom;
use shared_lock::StylesheetGuards; use shared_lock::StylesheetGuards;
use sharing::StyleSharingCandidateCache; use sharing::StyleSharingCache;
use std::fmt; use std::fmt;
use std::ops; use std::ops;
#[cfg(feature = "servo")] use std::sync::Mutex; #[cfg(feature = "servo")] use std::sync::Mutex;
@ -679,7 +679,7 @@ impl StackLimitChecker {
/// thread in order to be able to mutate it without locking. /// thread in order to be able to mutate it without locking.
pub struct ThreadLocalStyleContext<E: TElement> { pub struct ThreadLocalStyleContext<E: TElement> {
/// A cache to share style among siblings. /// A cache to share style among siblings.
pub style_sharing_candidate_cache: StyleSharingCandidateCache<E>, pub sharing_cache: StyleSharingCache<E>,
/// The bloom filter used to fast-reject selector-matching. /// The bloom filter used to fast-reject selector-matching.
pub bloom_filter: StyleBloom<E>, pub bloom_filter: StyleBloom<E>,
/// A channel on which new animations that have been triggered by style /// A channel on which new animations that have been triggered by style
@ -716,7 +716,7 @@ impl<E: TElement> ThreadLocalStyleContext<E> {
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
pub fn new(shared: &SharedStyleContext) -> Self { pub fn new(shared: &SharedStyleContext) -> Self {
ThreadLocalStyleContext { ThreadLocalStyleContext {
style_sharing_candidate_cache: StyleSharingCandidateCache::new(), sharing_cache: StyleSharingCache::new(),
bloom_filter: StyleBloom::new(), bloom_filter: StyleBloom::new(),
new_animations_sender: shared.local_context_creation_data.lock().unwrap().new_animations_sender.clone(), new_animations_sender: shared.local_context_creation_data.lock().unwrap().new_animations_sender.clone(),
tasks: SequentialTaskList(Vec::new()), tasks: SequentialTaskList(Vec::new()),
@ -733,7 +733,7 @@ impl<E: TElement> ThreadLocalStyleContext<E> {
/// Creates a new `ThreadLocalStyleContext` from a shared one. /// Creates a new `ThreadLocalStyleContext` from a shared one.
pub fn new(shared: &SharedStyleContext) -> Self { pub fn new(shared: &SharedStyleContext) -> Self {
ThreadLocalStyleContext { ThreadLocalStyleContext {
style_sharing_candidate_cache: StyleSharingCandidateCache::new(), sharing_cache: StyleSharingCache::new(),
bloom_filter: StyleBloom::new(), bloom_filter: StyleBloom::new(),
tasks: SequentialTaskList(Vec::new()), tasks: SequentialTaskList(Vec::new()),
selector_flags: SelectorFlagsMap::new(), selector_flags: SelectorFlagsMap::new(),

View file

@ -343,7 +343,7 @@ impl<E: TElement> StyleSharingTarget<E> {
&mut self, &mut self,
context: &mut StyleContext<E>, context: &mut StyleContext<E>,
) -> StyleSharingResult { ) -> StyleSharingResult {
let cache = &mut context.thread_local.style_sharing_candidate_cache; let cache = &mut context.thread_local.sharing_cache;
let shared_context = &context.shared; let shared_context = &context.shared;
let selector_flags_map = &mut context.thread_local.selector_flags; let selector_flags_map = &mut context.thread_local.selector_flags;
let bloom_filter = &context.thread_local.bloom_filter; let bloom_filter = &context.thread_local.bloom_filter;
@ -436,7 +436,7 @@ thread_local!(static SHARING_CACHE_KEY: StoredSharingCache =
/// ///
/// Note that this cache is flushed every time we steal work from the queue, so /// Note that this cache is flushed every time we steal work from the queue, so
/// storing nodes here temporarily is safe. /// storing nodes here temporarily is safe.
pub struct StyleSharingCandidateCache<E: TElement> { pub struct StyleSharingCache<E: TElement> {
/// The LRU cache, with the type cast away to allow persisting the allocation. /// The LRU cache, with the type cast away to allow persisting the allocation.
cache_typeless: OwningHandle<StoredSharingCache, AtomicRefMut<'static, TypelessSharingCache>>, cache_typeless: OwningHandle<StoredSharingCache, AtomicRefMut<'static, TypelessSharingCache>>,
/// Bind this structure to the lifetime of E, since that's what we effectively store. /// Bind this structure to the lifetime of E, since that's what we effectively store.
@ -447,13 +447,13 @@ pub struct StyleSharingCandidateCache<E: TElement> {
dom_depth: usize, dom_depth: usize,
} }
impl<E: TElement> Drop for StyleSharingCandidateCache<E> { impl<E: TElement> Drop for StyleSharingCache<E> {
fn drop(&mut self) { fn drop(&mut self) {
self.clear(); self.clear();
} }
} }
impl<E: TElement> StyleSharingCandidateCache<E> { impl<E: TElement> StyleSharingCache<E> {
fn cache(&self) -> &SharingCache<E> { fn cache(&self) -> &SharingCache<E> {
let base: &TypelessSharingCache = &*self.cache_typeless; let base: &TypelessSharingCache = &*self.cache_typeless;
unsafe { mem::transmute(base) } unsafe { mem::transmute(base) }
@ -472,7 +472,7 @@ impl<E: TElement> StyleSharingCandidateCache<E> {
let cache = OwningHandle::new_with_fn(cache_arc, |x| unsafe { x.as_ref() }.unwrap().borrow_mut()); let cache = OwningHandle::new_with_fn(cache_arc, |x| unsafe { x.as_ref() }.unwrap().borrow_mut());
debug_assert_eq!(cache.num_entries(), 0); debug_assert_eq!(cache.num_entries(), 0);
StyleSharingCandidateCache { StyleSharingCache {
cache_typeless: cache, cache_typeless: cache,
marker: PhantomData, marker: PhantomData,
dom_depth: 0, dom_depth: 0,

View file

@ -658,7 +658,7 @@ where
match target.share_style_if_possible(context) { match target.share_style_if_possible(context) {
StyleWasShared(index, styles) => { StyleWasShared(index, styles) => {
context.thread_local.statistics.styles_shared += 1; context.thread_local.statistics.styles_shared += 1;
context.thread_local.style_sharing_candidate_cache.touch(index); context.thread_local.sharing_cache.touch(index);
styles styles
} }
CannotShare => { CannotShare => {
@ -677,7 +677,7 @@ where
}; };
context.thread_local context.thread_local
.style_sharing_candidate_cache .sharing_cache
.insert_if_possible( .insert_if_possible(
&element, &element,
new_styles.primary(), new_styles.primary(),