Tidy fixes

This commit is contained in:
Manish Goregaokar 2017-09-01 08:31:30 -07:00
parent ce4e1e4194
commit 3ddb1fda74
7 changed files with 43 additions and 22 deletions

View file

@ -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};
@ -35,7 +44,6 @@ impl<K, V, S> DerefMut for HashMap<K, V, S> {
} }
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)))
} }
@ -109,7 +119,6 @@ impl<T, S> DerefMut for HashSet<T, S> {
} }
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,7 +166,8 @@ 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()
} }

View file

@ -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;

View file

@ -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};

View file

@ -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;

View file

@ -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;

View file

@ -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",