mirror of
https://github.com/servo/servo.git
synced 2025-07-01 20:43:39 +01:00
Tidy fixes
This commit is contained in:
parent
ce4e1e4194
commit
3ddb1fda74
7 changed files with 43 additions and 22 deletions
|
@ -14,4 +14,4 @@ libc = "0.2"
|
||||||
heapsize = "0.4"
|
heapsize = "0.4"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
rand = "0.3"
|
rand = "0.3"
|
||||||
|
|
|
@ -1,16 +1,25 @@
|
||||||
|
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
//! This module contains shims around the stdlib HashMap
|
//! This module contains shims around the stdlib HashMap
|
||||||
//! that add fallible methods
|
//! that add fallible methods
|
||||||
//!
|
//!
|
||||||
//! These methods are a lie. They are not actually fallible. This is just to make
|
//! These methods are a lie. They are not actually fallible. This is just to make
|
||||||
//! it smooth to switch between hashmap impls in a codebase.
|
//! it smooth to switch between hashmap impls in a codebase.
|
||||||
|
|
||||||
use std::hash::{BuildHasher, Hash};
|
use heapsize::HeapSizeOf;
|
||||||
use std::collections::HashMap as StdMap;
|
use std::collections::HashMap as StdMap;
|
||||||
use std::collections::HashSet as StdSet;
|
use std::collections::HashSet as StdSet;
|
||||||
use std::ops::{Deref, DerefMut};
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
use std::hash::{BuildHasher, Hash};
|
||||||
use heapsize::HeapSizeOf;
|
use std::ops::{Deref, DerefMut};
|
||||||
|
|
||||||
pub use std::collections::hash_map::{Entry, RandomState, Iter as MapIter, IterMut as MapIterMut};
|
pub use std::collections::hash_map::{Entry, RandomState, Iter as MapIter, IterMut as MapIterMut};
|
||||||
pub use std::collections::hash_set::{Iter as SetIter, IntoIter as SetIntoIter};
|
pub use std::collections::hash_set::{Iter as SetIter, IntoIter as SetIntoIter};
|
||||||
|
@ -25,17 +34,16 @@ impl<K, V, S> Deref for HashMap<K, V, S> {
|
||||||
type Target = StdMap<K, V, S>;
|
type Target = StdMap<K, V, S>;
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
&self.0
|
&self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<K, V, S> DerefMut for HashMap<K, V, S> {
|
impl<K, V, S> DerefMut for HashMap<K, V, S> {
|
||||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||||
&mut self.0
|
&mut self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<K: Hash + Eq, V> HashMap<K, V, RandomState> {
|
impl<K: Hash + Eq, V> HashMap<K, V, RandomState> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new() -> HashMap<K, V, RandomState> {
|
pub fn new() -> HashMap<K, V, RandomState> {
|
||||||
HashMap(StdMap::new())
|
HashMap(StdMap::new())
|
||||||
|
@ -63,7 +71,9 @@ impl<K, V, S> HashMap<K, V, S>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn try_with_capacity_and_hasher(capacity: usize, hash_builder: S) -> Result<HashMap<K, V, S>, FailedAllocationError> {
|
pub fn try_with_capacity_and_hasher(capacity: usize,
|
||||||
|
hash_builder: S)
|
||||||
|
-> Result<HashMap<K, V, S>, FailedAllocationError> {
|
||||||
Ok(HashMap(StdMap::with_capacity_and_hasher(capacity, hash_builder)))
|
Ok(HashMap(StdMap::with_capacity_and_hasher(capacity, hash_builder)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,17 +109,16 @@ impl<T, S> Deref for HashSet<T, S> {
|
||||||
type Target = StdSet<T, S>;
|
type Target = StdSet<T, S>;
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
&self.0
|
&self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, S> DerefMut for HashSet<T, S> {
|
impl<T, S> DerefMut for HashSet<T, S> {
|
||||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||||
&mut self.0
|
&mut self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Hash + Eq> HashSet<T, RandomState> {
|
impl<T: Hash + Eq> HashSet<T, RandomState> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new() -> HashSet<T, RandomState> {
|
pub fn new() -> HashSet<T, RandomState> {
|
||||||
HashSet(StdSet::new())
|
HashSet(StdSet::new())
|
||||||
|
@ -126,7 +135,6 @@ impl<T, S> HashSet<T, S>
|
||||||
where T: Eq + Hash,
|
where T: Eq + Hash,
|
||||||
S: BuildHasher
|
S: BuildHasher
|
||||||
{
|
{
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn with_hasher(hasher: S) -> HashSet<T, S> {
|
pub fn with_hasher(hasher: S) -> HashSet<T, S> {
|
||||||
HashSet(StdSet::with_hasher(hasher))
|
HashSet(StdSet::with_hasher(hasher))
|
||||||
|
@ -158,10 +166,11 @@ impl<T, S> HashSet<T, S>
|
||||||
// We can't derive these since the bounds are not obvious to the derive macro
|
// We can't derive these since the bounds are not obvious to the derive macro
|
||||||
|
|
||||||
|
|
||||||
impl<K: HeapSizeOf + Hash + Eq, V: HeapSizeOf, S: BuildHasher> HeapSizeOf for HashMap<K, V, S> {
|
impl<K: HeapSizeOf + Hash + Eq, V: HeapSizeOf, S: BuildHasher>
|
||||||
|
HeapSizeOf for HashMap<K, V, S> {
|
||||||
fn heap_size_of_children(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
self.0.heap_size_of_children()
|
self.0.heap_size_of_children()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<K: Hash + Eq, V, S: BuildHasher + Default> Default for HashMap<K, V, S> {
|
impl<K: Hash + Eq, V, S: BuildHasher + Default> Default for HashMap<K, V, S> {
|
||||||
|
@ -224,7 +233,7 @@ impl<'a, K, V, S> IntoIterator for &'a mut HashMap<K, V, S>
|
||||||
impl<T: HeapSizeOf + Eq + Hash, S: BuildHasher> HeapSizeOf for HashSet<T, S> {
|
impl<T: HeapSizeOf + Eq + Hash, S: BuildHasher> HeapSizeOf for HashSet<T, S> {
|
||||||
fn heap_size_of_children(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
self.0.heap_size_of_children()
|
self.0.heap_size_of_children()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Eq + Hash, S: BuildHasher + Default> Default for HashSet<T, S> {
|
impl<T: Eq + Hash, S: BuildHasher + Default> Default for HashSet<T, S> {
|
||||||
|
|
|
@ -1,12 +1,22 @@
|
||||||
|
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
pub use std::*;
|
pub use std::*;
|
||||||
|
|
||||||
extern crate heapsize;
|
extern crate heapsize;
|
||||||
|
|
||||||
mod table;
|
|
||||||
mod shim;
|
|
||||||
mod alloc;
|
mod alloc;
|
||||||
pub mod hash_map;
|
pub mod hash_map;
|
||||||
pub mod hash_set;
|
pub mod hash_set;
|
||||||
|
mod shim;
|
||||||
|
mod table;
|
||||||
|
|
||||||
pub mod fake;
|
pub mod fake;
|
||||||
|
|
||||||
|
|
|
@ -8,13 +8,13 @@
|
||||||
|
|
||||||
use Atom;
|
use Atom;
|
||||||
use cssparser::{Delimiter, Parser, ParserInput, SourcePosition, Token, TokenSerializationType};
|
use cssparser::{Delimiter, Parser, ParserInput, SourcePosition, Token, TokenSerializationType};
|
||||||
|
use hash::{HashMap, HashSet};
|
||||||
use parser::ParserContext;
|
use parser::ParserContext;
|
||||||
use properties::{CSSWideKeyword, DeclaredValue};
|
use properties::{CSSWideKeyword, DeclaredValue};
|
||||||
use selectors::parser::SelectorParseError;
|
use selectors::parser::SelectorParseError;
|
||||||
use servo_arc::Arc;
|
use servo_arc::Arc;
|
||||||
use std::ascii::AsciiExt;
|
use std::ascii::AsciiExt;
|
||||||
use std::borrow::{Borrow, Cow};
|
use std::borrow::{Borrow, Cow};
|
||||||
use hash::{HashMap, HashSet};
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
use style_traits::{ToCss, StyleParseError, ParseError};
|
use style_traits::{ToCss, StyleParseError, ParseError};
|
||||||
|
|
|
@ -66,6 +66,7 @@ use gecko_bindings::structs::nsChangeHint;
|
||||||
use gecko_bindings::structs::nsIDocument_DocumentTheme as DocumentTheme;
|
use gecko_bindings::structs::nsIDocument_DocumentTheme as DocumentTheme;
|
||||||
use gecko_bindings::structs::nsRestyleHint;
|
use gecko_bindings::structs::nsRestyleHint;
|
||||||
use gecko_bindings::sugar::ownership::{HasArcFFI, HasSimpleFFI};
|
use gecko_bindings::sugar::ownership::{HasArcFFI, HasSimpleFFI};
|
||||||
|
use hash::HashMap;
|
||||||
use logical_geometry::WritingMode;
|
use logical_geometry::WritingMode;
|
||||||
use media_queries::Device;
|
use media_queries::Device;
|
||||||
use properties::{ComputedValues, parse_style_attribute};
|
use properties::{ComputedValues, parse_style_attribute};
|
||||||
|
@ -83,7 +84,6 @@ use selectors::sink::Push;
|
||||||
use servo_arc::{Arc, ArcBorrow, RawOffsetArc};
|
use servo_arc::{Arc, ArcBorrow, RawOffsetArc};
|
||||||
use shared_lock::Locked;
|
use shared_lock::Locked;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use hash::HashMap;
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
|
@ -9,6 +9,8 @@ use {Atom, LocalName};
|
||||||
use applicable_declarations::ApplicableDeclarationBlock;
|
use applicable_declarations::ApplicableDeclarationBlock;
|
||||||
use context::QuirksMode;
|
use context::QuirksMode;
|
||||||
use dom::TElement;
|
use dom::TElement;
|
||||||
|
use hash::{HashMap, HashSet};
|
||||||
|
use hash::map as hash_map;
|
||||||
use pdqsort::sort_by;
|
use pdqsort::sort_by;
|
||||||
use precomputed_hash::PrecomputedHash;
|
use precomputed_hash::PrecomputedHash;
|
||||||
use rule_tree::CascadeLevel;
|
use rule_tree::CascadeLevel;
|
||||||
|
@ -16,8 +18,6 @@ use selector_parser::SelectorImpl;
|
||||||
use selectors::matching::{matches_selector, MatchingContext, ElementSelectorFlags};
|
use selectors::matching::{matches_selector, MatchingContext, ElementSelectorFlags};
|
||||||
use selectors::parser::{Component, Combinator, SelectorIter};
|
use selectors::parser::{Component, Combinator, SelectorIter};
|
||||||
use smallvec::{SmallVec, VecLike};
|
use smallvec::{SmallVec, VecLike};
|
||||||
use hash::{HashMap, HashSet};
|
|
||||||
use hash::map as hash_map;
|
|
||||||
use std::hash::{BuildHasherDefault, Hash, Hasher};
|
use std::hash::{BuildHasherDefault, Hash, Hasher};
|
||||||
use stylist::Rule;
|
use stylist::Rule;
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ lint-scripts = [
|
||||||
rand = [
|
rand = [
|
||||||
"deque",
|
"deque",
|
||||||
"gaol",
|
"gaol",
|
||||||
|
"hashglobe", # only uses in tests
|
||||||
"ipc-channel",
|
"ipc-channel",
|
||||||
"num-bigint",
|
"num-bigint",
|
||||||
"parking_lot_core",
|
"parking_lot_core",
|
||||||
|
@ -74,6 +75,7 @@ directories = [
|
||||||
"./components/script/dom/bindings/codegen/parser",
|
"./components/script/dom/bindings/codegen/parser",
|
||||||
"./components/script/dom/bindings/codegen/ply",
|
"./components/script/dom/bindings/codegen/ply",
|
||||||
"./python/_virtualenv",
|
"./python/_virtualenv",
|
||||||
|
"./components/hashglobe/src",
|
||||||
# Generated and upstream code combined with our own. Could use cleanup
|
# Generated and upstream code combined with our own. Could use cleanup
|
||||||
"./target",
|
"./target",
|
||||||
"./ports/cef",
|
"./ports/cef",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue