swc_common/
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
#[cfg(feature = "ahash")]
pub use self::ahash::*;
#[cfg(not(feature = "ahash"))]
pub use self::rustchash::*;

#[cfg(not(feature = "ahash"))]
mod rustchash {
    use std::{
        collections::{HashMap, HashSet},
        hash::BuildHasherDefault,
    };

    use rustc_hash::FxHasher;

    pub type ARandomState = BuildHasherDefault<FxHasher>;

    pub type AHashMap<K, V> = HashMap<K, V, ARandomState>;

    pub type AHashSet<V> = HashSet<V, ARandomState>;
}

#[cfg(feature = "ahash")]
mod ahash {
    use std::collections::{HashMap, HashSet};

    pub type ARandomState = ahash::RandomState;

    pub type AHashMap<K, V> = HashMap<K, V, ARandomState>;

    pub type AHashSet<V> = HashSet<V, ARandomState>;
}