Intern table for UTF-8 edge byte ranges, keyed by the exact 16-bit (lo << 8) | hi.
An open-addressed probe table over a flat buffer rather than std::unordered_map, because this builder must also run inside a constant expression: static_storage builds its byte program at compile time, and no node-based standard container is constexpr-constructible before C++23.
A slot holds (key << 16) | (index + 1), so a zero slot means empty and the range 0x00..0x00 stays a legal key. The table grows at half load rather than capping, so a pattern with many distinct Unicode classes degrades in speed and never in correctness — a fixed capacity would either fill and spin or silently stop interning.
| static constexpr std::size_t real::detail::range_intern_table::bucket |
( |
std::uint16_t |
key, |
|
|
std::size_t |
mask |
|
) |
| |
|
inlinestaticconstexprnoexcept |
Probe start for key: Fibonacci hashing — the key times 2^64/phi, keeping the high bits.
The keys cluster hard and arrive in near-runs (lo walks a trie node's disjoint ranges in order, and the continuation range 0x80..0xBF sits on nearly every node), so the stride between consecutive keys is what decides whether the table is used or a quarter of it is. Taking the high bits of the 64-bit product gives a stride coprime with the table size; the 32-bit constant shifted by a fixed amount does not — its stride shares a factor of 4 with 1024, so three of every four buckets would be unreachable for a run of keys and the reachable quarter would be over 100% loaded at the half-load rehash point. Wrapping is intended (it is the modular multiply).
- Parameters
-
| [in] | key | The 16-bit packed byte range. |
| [in] | mask | slots.size() - 1, the table being a power of two. |
- Returns
- The first bucket to probe.