From eddec5cc06123ca98cd9ecdfc393a14bd7ed779b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 11 Feb 2016 03:05:06 +0100 Subject: [PATCH] style: Use fnv hashing for pseudo-elements --- components/style/data.rs | 5 +++-- components/style/matching.rs | 6 +++--- components/style/selector_matching.rs | 7 ++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/components/style/data.rs b/components/style/data.rs index 244e97e362d..e2e806cee26 100644 --- a/components/style/data.rs +++ b/components/style/data.rs @@ -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 { pub style: Option>, /// The results of CSS styling for each pseudo-element (if any). - pub per_pseudo: HashMap>>, + pub per_pseudo: HashMap>, BuildHasherDefault<::fnv::FnvHasher>>, /// Information needed during parallel traversals. pub parallel: DomParallelInfo, @@ -23,7 +24,7 @@ impl PrivateStyleData { pub fn new() -> PrivateStyleData { PrivateStyleData { style: None, - per_pseudo: HashMap::new(), + per_pseudo: HashMap::with_hasher(Default::default()), parallel: DomParallelInfo::new(), } } diff --git a/components/style/matching.rs b/components/style/matching.rs index f4c5cd191cd..b33d9fcd6da 100644 --- a/components/style/matching.rs +++ b/components/style/matching.rs @@ -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 { pub normal: SmallVec<[DeclarationBlock; 16]>, - pub per_pseudo: HashMap>, + pub per_pseudo: HashMap, BuildHasherDefault<::fnv::FnvHasher>>, /// Whether the `normal` declarations are shareable with other nodes. pub normal_shareable: bool, @@ -64,7 +64,7 @@ impl ApplicableDeclarations { pub fn new() -> ApplicableDeclarations { let mut applicable_declarations = ApplicableDeclarations { normal: SmallVec::new(), - per_pseudo: HashMap::new(), + per_pseudo: HashMap::with_hasher(Default::default()), normal_shareable: false, }; diff --git a/components/style/selector_matching.rs b/components/style/selector_matching.rs index 5fa0d3ab1f3..be3ae5453fa 100644 --- a/components/style/selector_matching.rs +++ b/components/style/selector_matching.rs @@ -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 { // The current selector maps, after evaluating media // rules against the current device. element_map: PerPseudoElementSelectorMap, - pseudos_map: HashMap>, + pseudos_map: HashMap, BuildHasherDefault<::fnv::FnvHasher>>, rules_source_order: usize, // Selector dependencies used to compute restyle hints. @@ -115,7 +116,7 @@ impl Stylist { 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 Stylist { 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();