def message

bend-lint-rules@0.2.0.0 · performance/repeated_call.bend:66

import bend-lint-rules@0.2.0.0/performance/repeated_call.bend as RepeatedCall
import Base

66def message(callee: String, loop: String) -> String:
67  callee
68    ++ " is called again here, with the same arguments, on this path of "
69    ++ loop
70    ++ ", so Bend computes it twice: clang does not merge calls of a definition that loops. All lanes. Measured on the CPU: pow2(30) written `Nat.add(pow2(q), pow2(q))` took 3.4 s, against 0.1 s after the fix; in eldergrove-faire and in llama.bend's tokenizer, the fix changed nothing measurable, as those calls walk short lists. Confidence: medium, as the gain is what the call costs. Bind its value once, with `+` if it is used twice, and use that name. If the call is cheap, such as a walk of a short list, expect this finding."

Uses (2)

Used by (1)