OxL Reference

fn unlikely

c, which the optimizer may assume to be usually false: if unlikely(failed) { ... }.

Example:

oxl✓ checked in CI
use std.opt { unlikely }

fn main() io {
  let failed = false
  if unlikely(failed) {
    print("rare path")
  } else {
    print("usual path")
  }
}
Output
usual path
@intrinsic("opt.unlikely") pub(api) fn unlikely(c: bool) -> bool

Complexity. O(1); the hint costs nothing at run time.

Since. 1.0.0-beta

Parameters

NameType
cbool

Returns

bool

Effects

none declared (pure unless the body says otherwise)

Defined in: std/opt/opt.oxl:60

See also