Intern table for UTF-8 edge byte ranges, keyed by the exact 16-bit (lo << 8) | hi.
More...
#include <lazy_dfa.hpp>
|
| constexpr std::uint16_t | find (std::uint16_t key) const noexcept |
| | Returns the interned class index for key, or absent.
|
| |
| constexpr void | insert (std::uint16_t key, std::uint16_t idx) |
| | Records idx for key, doubling the table first when it would pass half load.
|
| |
|
| static constexpr std::size_t | bucket (std::uint16_t key, std::size_t mask) noexcept |
| | Probe start for key: Fibonacci hashing — the key times 2^64/phi, keeping the high bits.
|
| |
|
|
std::vector< std::uint32_t > | slots {std::vector<std::uint32_t>(1024U, 0U)} |
| | Power of two; 1024 covers the ~476 ranges a \w-heavy program interns without a rehash.
|
| |
|
std::size_t | count {0} |
| | Occupied slots, for the load factor.
|
| |
|
|
static constexpr std::uint16_t | absent {0xFFFFU} |
| | find's miss answer (never a valid index: it would be slot 0x10000).
|
| |
Intern table for UTF-8 edge byte ranges, keyed by the exact 16-bit (lo << 8) | hi.
Open-addressed over a flat buffer, not std::unordered_map: static_storage builds its byte program in a constant expression. A slot holds (key << 16) | (index + 1), so zero means empty and 0x00..0x00 stays a legal key. It grows at half load, never caps: a fixed capacity would fill and spin or silently stop interning.
◆ bucket()
| 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.
Keys arrive in near-runs, so the stride between consecutive keys decides the table's use. Keep the 64-bit product: a shifted 32-bit constant has a stride sharing a factor of 4 with 1024, leaving three buckets in four unreachable. Wrapping is the intended 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.
◆ find()
| constexpr std::uint16_t real::detail::range_intern_table::find |
( |
std::uint16_t |
key | ) |
const |
|
inlineconstexprnoexcept |
Returns the interned class index for key, or absent.
- Parameters
-
| [in] | key | The 16-bit packed byte range. |
- Returns
- The class index recorded for
key, or absent when it was never interned.
◆ insert()
| constexpr void real::detail::range_intern_table::insert |
( |
std::uint16_t |
key, |
|
|
std::uint16_t |
idx |
|
) |
| |
|
inlineconstexpr |
Records idx for key, doubling the table first when it would pass half load.
- Parameters
-
| [in] | key | The 16-bit packed byte range. |
| [in] | idx | The class index to record for it. |
The documentation for this struct was generated from the following file: