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
42
43
44
45
46
47
48
use MaybeUninit;
use HashMap;
/// A compact hash map that stores up to `N` key-value pairs inline and spills
/// to a heap-allocated [`HashMap`] when the inline capacity is exceeded.
///
/// For small maps (≤ `N` entries), all data lives on the stack with no heap
/// allocation. Lookups use h2-accelerated linear scan. When the map grows
/// beyond `N` entries it transparently spills to a [`hashbrown::HashMap`].
///
/// The default inline capacity is 8 entries.
///
/// # Examples
/// ```
/// use turbocow::SmallMap;
///
/// let mut map = SmallMap::<&str, i32>::new();
/// map.insert("hello", 1);
/// map.insert("world", 2);
/// assert_eq!(map.get("hello"), Some(&1));
/// assert_eq!(map.len(), 2);
/// ```
/// Flat inline storage for key-value pairs with h2 sidecar.
///
/// Entries and h2 bytes are stored in fixed-size arrays of capacity `N`.
/// All `N` h2 bytes are initialised to [`H2_EMPTY`](super::group::H2_EMPTY)
/// at construction time, ensuring SIMD reads are always safe. When the map
/// reaches `N` entries it spills to a hashbrown `HashMap`.
// ── Compile-time assertion ───────────────────────────────────────────────
// Intentional compile-time invariant guard; clippy flags the constant
// condition, but the assert documents the contract.
const _: = assert!;