performance/list_index_loop.bend fails
raw source on the hub · import bend-lint-rules@0.1.0.0/performance/list_index_loop.bend as List_index_loop
performance/list_index_loop: a loop that reads a list from its head on each step. A definition passes
a list parameter unchanged to a call of itself, and, in the same branch, gives it to List.get,
List.drop, List.take, List.last or List.length, or to a definition of the file that gives its
parameter to one of those.
Heuristics: each of those walks the list from its head, so a loop of n steps over a list of n items
takes O(n²) time, where walking the list takes O(n). A branch is the innermost case around the
read; the loop's call must be in it too. It looks one definition deep, not further. A read in a type
does not run, and is skipped. A read whose result is an argument of a call of the loop itself moves
the loop along the list (a step, or a split in two: bend-ml's tensor-array fills a tree of bands so),
and is not reported.
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 bend-lint-api@0.1.0.0/shared/names.bend as Names
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 |