mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
stylo: Replace all hashtable collections with ones from style::hash
This commit is contained in:
parent
fae5e10643
commit
5cd296a264
9 changed files with 29 additions and 14 deletions
9
Cargo.lock
generated
9
Cargo.lock
generated
|
@ -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)",
|
||||
|
|
|
@ -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};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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")]
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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<T> {
|
||||
pub struct SelectorMap<T: 'static> {
|
||||
/// A hash from an ID to rules which contain that ID selector.
|
||||
pub id_hash: MaybeCaseInsensitiveHashMap<Atom, SmallVec<[T; 1]>>,
|
||||
/// A hash from a class name to rules which contain that class selector.
|
||||
|
@ -111,7 +111,10 @@ fn sort_by_key<T, F: Fn(&T) -> K, K: Ord>(v: &mut [T], f: F) {
|
|||
sort_by(v, |a, b| f(a).cmp(&f(b)))
|
||||
}
|
||||
|
||||
impl<T> SelectorMap<T> {
|
||||
// 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<T: 'static> SelectorMap<T> {
|
||||
/// Trivially constructs an empty `SelectorMap`.
|
||||
pub fn new() -> Self {
|
||||
SelectorMap {
|
||||
|
@ -461,9 +464,12 @@ fn find_push<Str: Eq + Hash, V, VL>(map: &mut PrecomputedHashMap<Str, VL>,
|
|||
/// Wrapper for PrecomputedHashMap that does ASCII-case-insensitive lookup in quirks mode.
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct MaybeCaseInsensitiveHashMap<K: PrecomputedHash + Hash + Eq, V>(PrecomputedHashMap<K, V>);
|
||||
pub struct MaybeCaseInsensitiveHashMap<K: PrecomputedHash + Hash + Eq, V: 'static>(PrecomputedHashMap<K, V>);
|
||||
|
||||
impl<V> MaybeCaseInsensitiveHashMap<Atom, V> {
|
||||
// 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<V: 'static> MaybeCaseInsensitiveHashMap<Atom, V> {
|
||||
/// Empty map
|
||||
pub fn new() -> Self {
|
||||
MaybeCaseInsensitiveHashMap(PrecomputedHashMap::default())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue