diff --git a/components/hashglobe/src/fake.rs b/components/hashglobe/src/fake.rs index a19931f95ec..eed48fc9151 100644 --- a/components/hashglobe/src/fake.rs +++ b/components/hashglobe/src/fake.rs @@ -43,24 +43,6 @@ impl DerefMut for HashMap { } } -impl HashMap { - #[inline] - pub fn new() -> HashMap { - HashMap(StdMap::new()) - } - - #[inline] - pub fn with_capacity(capacity: usize) -> HashMap { - HashMap(StdMap::with_capacity(capacity)) - } - - #[inline] - pub fn try_with_capacity(capacity: usize) -> Result, FailedAllocationError> { - Ok(HashMap(StdMap::with_capacity(capacity))) - } -} - - impl HashMap where K: Eq + Hash, S: BuildHasher diff --git a/components/hashglobe/src/hash_map.rs b/components/hashglobe/src/hash_map.rs index 69bd06344e0..5b3f7b7c02b 100644 --- a/components/hashglobe/src/hash_map.rs +++ b/components/hashglobe/src/hash_map.rs @@ -583,42 +583,6 @@ impl HashMap } } -impl HashMap { - /// Creates an empty `HashMap`. - /// - /// # Examples - /// - /// ``` - /// use std::collections::HashMap; - /// let mut map: HashMap<&str, isize> = HashMap::new(); - /// ``` - #[inline] - pub fn new() -> HashMap { - Default::default() - } - - /// Creates an empty `HashMap` with the specified capacity. - /// - /// The hash map will be able to hold at least `capacity` elements without - /// reallocating. If `capacity` is 0, the hash map will not allocate. - /// - /// # Examples - /// - /// ``` - /// use std::collections::HashMap; - /// let mut map: HashMap<&str, isize> = HashMap::with_capacity(10); - /// ``` - #[inline] - pub fn with_capacity(capacity: usize) -> HashMap { - HashMap::with_capacity_and_hasher(capacity, Default::default()) - } - - #[inline] - pub fn try_with_capacity(capacity: usize) -> Result, FailedAllocationError> { - HashMap::try_with_capacity_and_hasher(capacity, Default::default()) - } -} - impl HashMap where K: Eq + Hash, S: BuildHasher diff --git a/components/hashglobe/src/hash_set.rs b/components/hashglobe/src/hash_set.rs index f712d1af600..e21880453c8 100644 --- a/components/hashglobe/src/hash_set.rs +++ b/components/hashglobe/src/hash_set.rs @@ -121,38 +121,6 @@ pub struct HashSet { map: HashMap, } -impl HashSet { - /// Creates an empty `HashSet`. - /// - /// # Examples - /// - /// ``` - /// use std::collections::HashSet; - /// let set: HashSet = HashSet::new(); - /// ``` - #[inline] - pub fn new() -> HashSet { - HashSet { map: HashMap::new() } - } - - /// Creates an empty `HashSet` with the specified capacity. - /// - /// The hash set will be able to hold at least `capacity` elements without - /// reallocating. If `capacity` is 0, the hash set will not allocate. - /// - /// # Examples - /// - /// ``` - /// use std::collections::HashSet; - /// let set: HashSet = HashSet::with_capacity(10); - /// assert!(set.capacity() >= 10); - /// ``` - #[inline] - pub fn with_capacity(capacity: usize) -> HashSet { - HashSet { map: HashMap::with_capacity(capacity) } - } -} - impl HashSet where T: Eq + Hash, S: BuildHasher diff --git a/components/style/dom.rs b/components/style/dom.rs index c749862a76b..4c57edcb1c5 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -28,7 +28,7 @@ use selectors::sink::Push; use servo_arc::{Arc, ArcBorrow}; use shared_lock::Locked; use std::fmt; -#[cfg(feature = "gecko")] use hash::HashMap; +#[cfg(feature = "gecko")] use hash::FnvHashMap; use std::fmt::Debug; use std::hash::Hash; use std::ops::Deref; @@ -648,10 +648,10 @@ pub trait TElement : Eq + PartialEq + Debug + Hash + Sized + Copy + Clone + false } - /// Gets the current existing CSS transitions, by |property, end value| pairs in a HashMap. + /// Gets the current existing CSS transitions, by |property, end value| pairs in a FnvHashMap. #[cfg(feature = "gecko")] fn get_css_transitions_info(&self) - -> HashMap>; + -> FnvHashMap>; /// Does a rough (and cheap) check for whether or not transitions might need to be updated that /// will quickly return false for the common case of no transitions specified or running. If @@ -684,7 +684,7 @@ pub trait TElement : Eq + PartialEq + Debug + Hash + Sized + Copy + Clone + combined_duration: f32, before_change_style: &ComputedValues, after_change_style: &ComputedValues, - existing_transitions: &HashMap> + existing_transitions: &FnvHashMap> ) -> bool; /// Returns the value of the `xml:lang=""` attribute (or, if appropriate, diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index 5c709814dc6..a32d86bb3b1 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -66,7 +66,7 @@ use gecko_bindings::structs::nsChangeHint; use gecko_bindings::structs::nsIDocument_DocumentTheme as DocumentTheme; use gecko_bindings::structs::nsRestyleHint; use gecko_bindings::sugar::ownership::{HasArcFFI, HasSimpleFFI}; -use hash::HashMap; +use hash::FnvHashMap; use logical_geometry::WritingMode; use media_queries::Device; use properties::{ComputedValues, LonghandId, parse_style_attribute}; @@ -1303,14 +1303,14 @@ impl<'le> TElement for GeckoElement<'le> { fn get_css_transitions_info( &self, - ) -> HashMap> { + ) -> FnvHashMap> { use gecko_bindings::bindings::Gecko_ElementTransitions_EndValueAt; use gecko_bindings::bindings::Gecko_ElementTransitions_Length; use gecko_bindings::bindings::Gecko_ElementTransitions_PropertyAt; let collection_length = unsafe { Gecko_ElementTransitions_Length(self.0) }; - let mut map = HashMap::with_capacity(collection_length); + let mut map = FnvHashMap::with_capacity_and_hasher(collection_length, Default::default()); for i in 0..collection_length { let (property, raw_end_value) = unsafe { (Gecko_ElementTransitions_PropertyAt(self.0, i as usize).into(), @@ -1447,7 +1447,7 @@ impl<'le> TElement for GeckoElement<'le> { combined_duration: f32, before_change_style: &ComputedValues, after_change_style: &ComputedValues, - existing_transitions: &HashMap>, + existing_transitions: &FnvHashMap>, ) -> bool { use values::animated::{Animate, Procedure}; diff --git a/components/style/properties/longhand/position.mako.rs b/components/style/properties/longhand/position.mako.rs index 11bea2992fe..1eb1582134f 100644 --- a/components/style/properties/longhand/position.mako.rs +++ b/components/style/properties/longhand/position.mako.rs @@ -414,7 +414,7 @@ ${helpers.predefined_type("object-position", products="gecko" animation_value_type="discrete" boxed="True"> - use hash::HashMap; + use hash::FnvHashMap; use std::fmt; use std::ops::Range; use str::HTML_SPACE_CHARACTERS; @@ -478,7 +478,7 @@ ${helpers.predefined_type("object-position", let mut width = 0; { let mut row = 0u32; - let mut area_indices = HashMap::<(&str), usize>::new(); + let mut area_indices = FnvHashMap::<(&str), usize>::default(); for string in &strings { let mut current_area_index: Option = None; row += 1; diff --git a/components/style/rule_tree/mod.rs b/components/style/rule_tree/mod.rs index 51d70913e66..9de2e3daadd 100644 --- a/components/style/rule_tree/mod.rs +++ b/components/style/rule_tree/mod.rs @@ -1016,13 +1016,13 @@ impl StrongRuleNode { unsafe fn assert_free_list_has_no_duplicates_or_null(&self) { assert!(cfg!(debug_assertions), "This is an expensive check!"); - use hash::HashSet; + use hash::FnvHashSet; let me = &*self.ptr(); assert!(me.is_root()); let mut current = self.ptr(); - let mut seen = HashSet::new(); + let mut seen = FnvHashSet::default(); while current != FREE_LIST_SENTINEL { let next = (*current).next_free.load(Ordering::Relaxed); assert!(!next.is_null());