performance/repeated_call.bend fails
raw source on the hub · import bend-lint-rules@0.1.0.0/performance/repeated_call.bend as Repeated_call
performance/repeated_call: a call made again, with the same arguments, on one path of a definition: a
second call of a definition of the file that loops and returns a number, with its arguments written the
same way, in the same branch (the innermost case around both, or the definition's body).
Heuristics: clang does not merge two calls of a definition that loops: Bend runs each through its own
calls. Measured on the CPU, pow2(30) written Nat.add(pow2(q), pow2(q)) took 3.4 s; with the two calls
forked (a parallel let), 0.6 s; computed once (+h = pow2(q)), 0.1 s, the program's start. In
eldergrove-faire and in llama.bend's tokenizer, computing such calls once changed nothing measurable:
they walk short lists. Arguments are the same when written the same way: the same variables, literals,
and calls or constructions of them. Calls in a lambda, in a type, in a proof, or in the values of
Bool.pick, && or || (which performance/eager_branch judges) do not count, nor do the values of one
parallel let: copies made in parallel on purpose, as benchmarks do. A call that
performance/loop_invariant_call reports is left to it: computing it once before the loop also ends the
repeat. Only a number is sure to be shareable at no cost: data may be affine (an Array), so that it
must be built twice, and sharing it counts references; it is skipped. Numbers are those of
performance/gpu_fit, as the callee's return type is written.
8 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 bend-lint-api@0.1.0.0/shared/names.bend as Names import ./deep_call_in_fork.bend as Deep import ./gpu_fit.bend as GpuFit import ./loop_invariant_call.bend as Invariant import ./missed_fork.bend as Fork
The reader could not load this file (at 0x2b0a0dcada30f71a8eb4ec2e148b9279/linter/lint.bend:522). What bend.ts says:
Error:
- expected : a fresh constructor name (duplicate declaration: Text)
- observed : 'Text'
Location:
521 | Flag{on: Bool}
522>| Text{text: String}
| ^^^^
523 |