mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
stylo: use FnvHashMap everywhere, remove default HashMap construction methods
This commit is contained in:
parent
0b69887387
commit
8bce37e6ba
7 changed files with 12 additions and 98 deletions
|
@ -43,24 +43,6 @@ impl<K, V, S> DerefMut for HashMap<K, V, S> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<K: Hash + Eq, V> HashMap<K, V, RandomState> {
|
||||
#[inline]
|
||||
pub fn new() -> HashMap<K, V, RandomState> {
|
||||
HashMap(StdMap::new())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn with_capacity(capacity: usize) -> HashMap<K, V, RandomState> {
|
||||
HashMap(StdMap::with_capacity(capacity))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn try_with_capacity(capacity: usize) -> Result<HashMap<K, V, RandomState>, FailedAllocationError> {
|
||||
Ok(HashMap(StdMap::with_capacity(capacity)))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl<K, V, S> HashMap<K, V, S>
|
||||
where K: Eq + Hash,
|
||||
S: BuildHasher
|
||||
|
|
|
@ -583,42 +583,6 @@ impl<K, V, S> HashMap<K, V, S>
|
|||
}
|
||||
}
|
||||
|
||||
impl<K: Hash + Eq, V> HashMap<K, V, RandomState> {
|
||||
/// Creates an empty `HashMap`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::HashMap;
|
||||
/// let mut map: HashMap<&str, isize> = HashMap::new();
|
||||
/// ```
|
||||
#[inline]
|
||||
pub fn new() -> HashMap<K, V, RandomState> {
|
||||
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<K, V, RandomState> {
|
||||
HashMap::with_capacity_and_hasher(capacity, Default::default())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn try_with_capacity(capacity: usize) -> Result<HashMap<K, V, RandomState>, FailedAllocationError> {
|
||||
HashMap::try_with_capacity_and_hasher(capacity, Default::default())
|
||||
}
|
||||
}
|
||||
|
||||
impl<K, V, S> HashMap<K, V, S>
|
||||
where K: Eq + Hash,
|
||||
S: BuildHasher
|
||||
|
|
|
@ -121,38 +121,6 @@ pub struct HashSet<T, S = RandomState> {
|
|||
map: HashMap<T, (), S>,
|
||||
}
|
||||
|
||||
impl<T: Hash + Eq> HashSet<T, RandomState> {
|
||||
/// Creates an empty `HashSet`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::HashSet;
|
||||
/// let set: HashSet<i32> = HashSet::new();
|
||||
/// ```
|
||||
#[inline]
|
||||
pub fn new() -> HashSet<T, RandomState> {
|
||||
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<i32> = HashSet::with_capacity(10);
|
||||
/// assert!(set.capacity() >= 10);
|
||||
/// ```
|
||||
#[inline]
|
||||
pub fn with_capacity(capacity: usize) -> HashSet<T, RandomState> {
|
||||
HashSet { map: HashMap::with_capacity(capacity) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, S> HashSet<T, S>
|
||||
where T: Eq + Hash,
|
||||
S: BuildHasher
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue