style: Use fnv hashing for pseudo-elements

This commit is contained in:
Emilio Cobos Álvarez 2016-02-11 03:05:06 +01:00
parent dd503dfacb
commit eddec5cc06
3 changed files with 10 additions and 8 deletions

View file

@ -5,6 +5,7 @@
use properties::ComputedValues;
use selectors::parser::SelectorImpl;
use std::collections::HashMap;
use std::hash::BuildHasherDefault;
use std::sync::Arc;
use std::sync::atomic::AtomicIsize;
@ -13,7 +14,7 @@ pub struct PrivateStyleData<Impl: SelectorImpl> {
pub style: Option<Arc<ComputedValues>>,
/// The results of CSS styling for each pseudo-element (if any).
pub per_pseudo: HashMap<Impl::PseudoElement, Option<Arc<ComputedValues>>>,
pub per_pseudo: HashMap<Impl::PseudoElement, Option<Arc<ComputedValues>>, BuildHasherDefault<::fnv::FnvHasher>>,
/// Information needed during parallel traversals.
pub parallel: DomParallelInfo,
@ -23,7 +24,7 @@ impl<Impl: SelectorImpl> PrivateStyleData<Impl> {
pub fn new() -> PrivateStyleData<Impl> {
PrivateStyleData {
style: None,
per_pseudo: HashMap::new(),
per_pseudo: HashMap::with_hasher(Default::default()),
parallel: DomParallelInfo::new(),
}
}

View file

@ -17,7 +17,7 @@ use selectors::matching::{CommonStyleAffectingAttributeMode, CommonStyleAffectin
use selectors::matching::{common_style_affecting_attributes, rare_style_affecting_attributes};
use smallvec::SmallVec;
use std::collections::HashMap;
use std::hash::{Hash, Hasher};
use std::hash::{BuildHasherDefault, Hash, Hasher};
use std::slice::Iter;
use std::sync::mpsc::Sender;
use std::sync::{Arc, Mutex};
@ -54,7 +54,7 @@ fn create_common_style_affecting_attributes_from_element<'le, E: TElement<'le>>(
pub struct ApplicableDeclarations<Impl: SelectorImplExt> {
pub normal: SmallVec<[DeclarationBlock; 16]>,
pub per_pseudo: HashMap<Impl::PseudoElement, Vec<DeclarationBlock>>,
pub per_pseudo: HashMap<Impl::PseudoElement, Vec<DeclarationBlock>, BuildHasherDefault<::fnv::FnvHasher>>,
/// Whether the `normal` declarations are shareable with other nodes.
pub normal_shareable: bool,
@ -64,7 +64,7 @@ impl<Impl: SelectorImplExt> ApplicableDeclarations<Impl> {
pub fn new() -> ApplicableDeclarations<Impl> {
let mut applicable_declarations = ApplicableDeclarations {
normal: SmallVec::new(),
per_pseudo: HashMap::new(),
per_pseudo: HashMap::with_hasher(Default::default()),
normal_shareable: false,
};

View file

@ -19,6 +19,7 @@ use selectors::matching::{Rule, SelectorMap};
use selectors::parser::SelectorImpl;
use smallvec::VecLike;
use std::collections::HashMap;
use std::hash::BuildHasherDefault;
use std::process;
use std::sync::Arc;
use style_traits::viewport::ViewportConstraints;
@ -98,7 +99,7 @@ pub struct Stylist<Impl: SelectorImplExt> {
// The current selector maps, after evaluating media
// rules against the current device.
element_map: PerPseudoElementSelectorMap<Impl>,
pseudos_map: HashMap<Impl::PseudoElement, PerPseudoElementSelectorMap<Impl>>,
pseudos_map: HashMap<Impl::PseudoElement, PerPseudoElementSelectorMap<Impl>, BuildHasherDefault<::fnv::FnvHasher>>,
rules_source_order: usize,
// Selector dependencies used to compute restyle hints.
@ -115,7 +116,7 @@ impl<Impl: SelectorImplExt> Stylist<Impl> {
quirks_mode: false,
element_map: PerPseudoElementSelectorMap::new(),
pseudos_map: HashMap::new(),
pseudos_map: HashMap::with_hasher(Default::default()),
rules_source_order: 0,
state_deps: DependencySet::new(),
};
@ -136,7 +137,7 @@ impl<Impl: SelectorImplExt> Stylist<Impl> {
return false;
}
self.element_map = PerPseudoElementSelectorMap::new();
self.pseudos_map = HashMap::new();
self.pseudos_map = HashMap::with_hasher(Default::default());
self.rules_source_order = 0;
self.state_deps.clear();