swc_allocator/
collections.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//! Various collections.

use std::hash::BuildHasherDefault;

use rustc_hash::FxHasher;

#[cfg(feature = "nightly")]
use crate::FastAlloc;

/// See [std::collections::HashMap].
#[cfg(feature = "nightly")]
pub type HashMap<K, V, S> = hashbrown::HashMap<K, V, S, FastAlloc>;

/// See [std::collections::HashSet].
#[cfg(feature = "nightly")]
pub type HashSet<T, S> = hashbrown::HashSet<T, S, FastAlloc>;

/// See [std::collections::HashMap].
#[cfg(not(feature = "nightly"))]
pub type HashMap<K, V, S> = hashbrown::HashMap<K, V, S>;

#[cfg(not(feature = "nightly"))]
/// See [std::collections::HashSet].
pub type HashSet<T, S> = hashbrown::HashSet<T, S>;

/// Used for `FxHashMap` and `FxHashSet`.
pub type FxBuildHasher = BuildHasherDefault<FxHasher>;

/// Faster `HashMap` which uses `FxHasher`.
pub type FxHashMap<K, V> = HashMap<K, V, FxBuildHasher>;

/// Faster `HashSet` which uses `FxHasher`.
pub type FxHashSet<T> = HashSet<T, FxBuildHasher>;

/// Re-export for convenience.
pub use hashbrown::hash_map;