module std.opt
std.opt — hints for the optimizer (D-7690, D-7691). They never change the result of a program.
Example:
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
likely | c, which the optimizer may assume to be usually true |
unlikely | c, which the optimizer may assume to be usually false |