~/bend-docscommunity

performance/eager_branch.bend fails

raw source on the hub · import bend-lint-rules@0.1.0.0/performance/eager_branch.bend as Eager_branch

performance/eager_branch: a value that Bend computes even when it is not needed, and that calls a definition of the file that calls itself outside a tail position: a value of Bool.pick, or the right side of && or ||. These are functions, so their arguments are computed before they choose; a match runs only its chosen case. Heuristics: measured on the CPU, a Bool.pick whose unused value called a doubly recursive fib took 0.28 s, against 0.055 s for a match. A loop whose calls of itself are all tail calls is not reported: clang drops it when its value is unused (under Bool.pick, a 2G-step loop cost nothing measurable), though the JS lane still runs it. A loop's own call in && or || is never a tail call. A call of a definition that does not call itself, or of Base, is cheap and not reported. A value in a lambda, a type or an equation does not run, and is skipped; an erased argument (a proof's) is not told from a live one. A loop that is short in practice makes a finding that costs little to ignore.

4 imports
import Base
import bend-lint-api@0.1.0.0/linter/lint.bend as Lint
import bend-lint-api@0.1.0.0/shared/lists.bend as Lists
import ./deep_call_in_fork.bend as Deep