def message
bend-lint-rules@0.2.0.0 · performance/loop_invariant_call.bend:23
import bend-lint-rules@0.2.0.0/performance/loop_invariant_call.bend as LoopInvariantCall
import Base
23
24
25def message(callee: String, loop: String) -> String:
26 callee
27 ++ " gets the same arguments on every step of "
28 ++ loop
29 ++ ", so it computes the same value each time: clang hoists plain arithmetic out of a loop, but not a call of a definition that loops. All lanes. Confidence: medium, as the gain is what the call costs. Compute it once before the loop, and pass it as a parameter. If the call is cheap, or the loop repeats it on purpose (a benchmark), expect this finding."