forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

hits.rs47 lines, 1.6 KiBHistoryRawDownload
1//! Gate-counter bumps, compiled out when the `gate-counters` feature is off.
2//!
3//! The ~550 `*_HITS` thread-locals in this crate exist only so the test gates
4//! (and the probe's census print) can prove a coding path fired; every bump is
5//! a TLS access plus a `Cell` read-modify-write on the parse thread. Routing
6//! all of them through [`hit!`]/[`hit_do!`] lets a shipped decoder drop them
7//! (`--no-default-features`) while the accessors keep compiling and returning
8//! whatever the counters hold (0 when the feature is off), so no caller needs
9//! a `cfg`.
10
11/// Bumps counter `$name` by one -- nothing at all without `gate-counters`.
12/// Usable in expression position (it evaluates to `()`).
13#[cfg(feature = "gate-counters")]
14macro_rules! hit {
15 ($name:ident) => {{
16 $name.with(|c| c.set(c.get() + 1));
17 }};
18}
19
20#[cfg(not(feature = "gate-counters"))]
21macro_rules! hit {
22 ($name:ident) => {{}};
23}
24
25/// Same, for a bump that is not a plain `+= 1` (array/tuple buckets, the
26/// `inter_last_mc` stamp, the counter-only scan loops): the whole statement
27/// list disappears without `gate-counters`.
28#[cfg(feature = "gate-counters")]
29macro_rules! hit_do {
30 ($($t:tt)*) => {{
31 $($t)*
32 }};
33}
34
35// Without the feature the statements stay type-checked but unreachable, so the
36// values they read (bucket indices, filter kinds) still count as used and the
37// optimiser drops the whole branch.
38#[cfg(not(feature = "gate-counters"))]
39macro_rules! hit_do {
40 ($($t:tt)*) => {{
41 if false {
42 $($t)*
43 }
44 }};
45}
46
47pub(crate) use {hit, hit_do};