def message

bend-lint-rules@0.2.0.0 · performance/eager_branch.bend:98

import bend-lint-rules@0.2.0.0/performance/eager_branch.bend as EagerBranch
import Base

98def message(kind: String, +callee: String, own: Bool) -> String:
99  why(
100    kind,
101    callee
102  )
103    ++ Bool.pick(
104      String,
105      own,
106      ": it is the loop's own call, so the loop walks to its end instead of stopping where the condition decides",
107      ""
108    )
109    ++ ". CPU and GPU: measured 5x slower than a match, for an unused call that calls itself outside a tail position. JS: computes both values too. Confidence: medium, as the cost is what the unneeded call computes. Choose with a match: pass the condition to a helper whose match runs only the needed value; inside a loop, where that helper would call the loop back (Bend refuses mutual recursion), pass the condition to the next call, and match on it there. If "
110    ++ callee
111    ++ " runs only a few steps here, expect this finding."

Uses (5)

Used by (1)