OxL Reference

fn likely

c, which the optimizer may assume to be usually true: if likely(x > 0) { ... }.

Example:

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

fn main() io {
  var sum = 0
  for i in 1..=10 {
    if likely(i > 0) { sum += i }
  }
  print("{sum}")
}
Output
55
@intrinsic("opt.likely") pub(api) fn likely(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:39

See also