OxL Reference

module std.opt

std.opt — hints for the optimizer (D-7690, D-7691). They never change the result of a program.

Example:

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

fn classify(n: i64) -> str {
  if unlikely(n < 0) { return "negative" }
  if likely(n > 0) { "positive" } else { "zero" }
}

fn main() io {
  print("{classify(5)} {classify(0)} {classify(-1)}")
}
Output
positive zero negative

Functions

likelyc, which the optimizer may assume to be usually true
unlikelyc, which the optimizer may assume to be usually false

See also