diff --git a/Cargo.lock b/Cargo.lock index 7b84ce75070..bce891473bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1242,6 +1242,14 @@ dependencies = [ "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "hashglobe" +version = "0.1.0" +dependencies = [ + "libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "heapsize" version = "0.4.0" @@ -3078,6 +3086,7 @@ dependencies = [ "encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "hashglobe 0.1.0", "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "html5ever 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/components/style/custom_properties.rs b/components/style/custom_properties.rs index f52495120f4..a318fce8b80 100644 --- a/components/style/custom_properties.rs +++ b/components/style/custom_properties.rs @@ -14,7 +14,7 @@ use selectors::parser::SelectorParseError; use servo_arc::Arc; use std::ascii::AsciiExt; use std::borrow::{Borrow, Cow}; -use std::collections::{HashMap, HashSet}; +use hash::{HashMap, HashSet}; use std::fmt; use std::hash::Hash; use style_traits::{ToCss, StyleParseError, ParseError}; diff --git a/components/style/dom.rs b/components/style/dom.rs index 9c1f8f44a2e..c1ea477960a 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -28,7 +28,7 @@ use servo_arc::{Arc, ArcBorrow}; use shared_lock::Locked; use smallvec::VecLike; use std::fmt; -#[cfg(feature = "gecko")] use std::collections::HashMap; +#[cfg(feature = "gecko")] use hash::HashMap; use std::fmt::Debug; use std::hash::Hash; use std::ops::Deref; diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index de534fe6d8a..d3c6f82bc32 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -83,7 +83,7 @@ use selectors::sink::Push; use servo_arc::{Arc, ArcBorrow, RawOffsetArc}; use shared_lock::Locked; use std::cell::RefCell; -use std::collections::HashMap; +use hash::HashMap; use std::fmt; use std::hash::{Hash, Hasher}; use std::mem; @@ -1361,7 +1361,7 @@ impl<'le> TElement for GeckoElement<'le> { after_change_style: &ComputedValues) -> bool { use gecko_bindings::structs::nsCSSPropertyID; - use std::collections::HashSet; + use hash::HashSet; debug_assert!(self.might_need_transitions_update(Some(before_change_style), after_change_style), diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index f598f28445d..7cf4da4646d 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -31,7 +31,7 @@ use selectors::parser::SelectorParseError; use smallvec::SmallVec; use std::borrow::Cow; use std::cmp; -#[cfg(feature = "gecko")] use fnv::FnvHashMap; +#[cfg(feature = "gecko")] use hash::FnvHashMap; use style_traits::ParseError; use super::ComputedValues; #[cfg(feature = "gecko")] diff --git a/components/style/properties/longhand/position.mako.rs b/components/style/properties/longhand/position.mako.rs index 03c5d155588..e1cd423a689 100644 --- a/components/style/properties/longhand/position.mako.rs +++ b/components/style/properties/longhand/position.mako.rs @@ -416,7 +416,7 @@ ${helpers.predefined_type("object-position", products="gecko" animation_value_type="discrete" boxed="True"> - use std::collections::HashMap; + use hash::HashMap; use std::fmt; use std::ops::Range; use str::HTML_SPACE_CHARACTERS; diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index a45c9937821..cfb7e04c1f3 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -13,7 +13,7 @@ #[cfg(feature = "servo")] use app_units::Au; use servo_arc::{Arc, UniqueArc}; use std::borrow::Cow; -use std::collections::HashSet; +use hash::HashSet; use std::{fmt, mem, ops}; #[cfg(feature = "gecko")] use std::ptr; diff --git a/components/style/rule_tree/mod.rs b/components/style/rule_tree/mod.rs index 7e76d3b34d4..b5b51291535 100644 --- a/components/style/rule_tree/mod.rs +++ b/components/style/rule_tree/mod.rs @@ -1000,7 +1000,7 @@ impl StrongRuleNode { unsafe fn assert_free_list_has_no_duplicates_or_null(&self) { assert!(cfg!(debug_assertions), "This is an expensive check!"); - use std::collections::HashSet; + use hash::HashSet; let me = &*self.ptr(); assert!(me.is_root()); diff --git a/components/style/selector_map.rs b/components/style/selector_map.rs index 139a2fd95f6..6b0f386b150 100644 --- a/components/style/selector_map.rs +++ b/components/style/selector_map.rs @@ -16,8 +16,8 @@ use selector_parser::SelectorImpl; use selectors::matching::{matches_selector, MatchingContext, ElementSelectorFlags}; use selectors::parser::{Component, Combinator, SelectorIter}; use smallvec::{SmallVec, VecLike}; -use std::collections::{HashMap, HashSet}; -use std::collections::hash_map; +use hash::{HashMap, HashSet}; +use hash::map as hash_map; use std::hash::{BuildHasherDefault, Hash, Hasher}; use stylist::Rule; @@ -93,7 +93,7 @@ pub trait SelectorMapEntry : Sized + Clone { /// TODO: Tune the initial capacity of the HashMap #[derive(Debug)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -pub struct SelectorMap { +pub struct SelectorMap { /// A hash from an ID to rules which contain that ID selector. pub id_hash: MaybeCaseInsensitiveHashMap>, /// A hash from a class name to rules which contain that class selector. @@ -111,7 +111,10 @@ fn sort_by_key K, K: Ord>(v: &mut [T], f: F) { sort_by(v, |a, b| f(a).cmp(&f(b))) } -impl SelectorMap { +// FIXME(Manishearth) the 'static bound can be removed when +// our HashMap fork (hashglobe) is able to use NonZero, +// or when stdlib gets fallible collections +impl SelectorMap { /// Trivially constructs an empty `SelectorMap`. pub fn new() -> Self { SelectorMap { @@ -461,9 +464,12 @@ fn find_push(map: &mut PrecomputedHashMap, /// Wrapper for PrecomputedHashMap that does ASCII-case-insensitive lookup in quirks mode. #[derive(Debug)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -pub struct MaybeCaseInsensitiveHashMap(PrecomputedHashMap); +pub struct MaybeCaseInsensitiveHashMap(PrecomputedHashMap); -impl MaybeCaseInsensitiveHashMap { +// FIXME(Manishearth) the 'static bound can be removed when +// our HashMap fork (hashglobe) is able to use NonZero, +// or when stdlib gets fallible collections +impl MaybeCaseInsensitiveHashMap { /// Empty map pub fn new() -> Self { MaybeCaseInsensitiveHashMap(PrecomputedHashMap::default())