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
37
38
39
40
41
//! The hash maps and sets of mln-rs.
//!
//! Their keys include layer IDs, source IDs and feature properties from
//! styles and tiles off the network, so the hasher has to resist keys crafted
//! to collide. foldhash's `RandomState` seeds each process from its address
//! space layout and the clock, and hashes short keys much faster than std's
//! default hasher. In the browser's wasm32-unknown-unknown, where there is no
//! clock or address randomization to read, its seed comes from addresses
//! alone, as std's does there.
/// The [`BuildHasher`](std::hash::BuildHasher) of [`HashMap`] and [`HashSet`].
pub type RandomState = RandomState;
/// The benchmarks' builds (`tools/bench/profile.toml`) set the
/// `mln_bench_fixed_hash` cfg, which gives every map the same seed, so that
/// each process hashes alike and a benchmark does the same work every run.
pub type RandomState = FixedState;
/// Whether [`RandomState`] has a fixed seed, as in the benchmarks' builds.
pub const SEED_IS_FIXED: bool = cfg!;
/// A [`std::collections::HashMap`] with mln-rs's hasher. Create one with
/// `default()`, or `with_capacity_and_hasher(n, RandomState::default())`.
pub type HashMap<K, V> = HashMap;
/// A [`std::collections::HashSet`] with mln-rs's hasher. Create one with
/// `default()`, or `with_capacity_and_hasher(n, RandomState::default())`.
pub type HashSet<T> = HashSet;
/// A hash of `bytes` that is the same for the same bytes throughout the
/// process, to tell whether data changed without keeping a copy of it.