Closed timotheecour closed 5 years ago
But cond
might not be used at all. It would complicate the compiler while the dev can just put the likely himself.
iterator zip(a, b: openarray[int]): (int, int) =
assert a.len == b.len
for i in 0 ..< a.len:
yield (a[i], b[i])
Also likely
is often placebo nowadays. After taking a single branch once the CPU branch predictor already takes that into account.
You can't use likely
here (the condition is not evaluated at all!), you can use assume
though. Except that Nim has no assume
and it seems a bad idea for robust software.
Not gonna happen. assume
is not the same as assert
.
in release with
--assertions:off
, instead of just discarding the assert, we should use it as optimization hint, eg transformingassert cond
intolikely(cond)
here's
likely
for reference: