Expand description
Branch-prediction hints for hot handlers.
Both functions are identity over bool on every supported
target. The call site cost is zero: the compiler inlines them
into the containing branch with no runtime effect. What they
communicate is intent. A handler that expects the fast path to
win 99% of the time writes
if hopper::utils::hint::likely(is_cached) {
return fast_path(ctx);
}
slow_path(ctx)and the compiler keeps the fast path straight-line, pushing the
spill into the cold branch. Same story for [unlikely] in the
opposite direction.
On host targets (tests, off-chain tooling) future versions may
route through core::intrinsics::likely when that intrinsic is
stabilized; the API shape stays identical so user code never
needs to change. On SBF the Solana runtime does not expose a
branch-weight hint today, so the hint compiles out entirely.
Leaving the calls in the code path is safe and free.