def costly

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

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

279# The definitions of the program a call of which runs a loop to its end, even when its value is unused: a loop that does
280# not compile to a native loop, as its body, or one it calls, keeps it from that (see program.unflat); or a definition
281# that calls such a loop.
282def costly(+sources: List<&2, Lint.Source>, +defs: Map<&2, Maybe<&2, Lint.Def>>) -> Set():
283  Lint.Program.callers(
284    sources,
285    defs,
286    Set.from_list(
287      loops(
288        Map.keys(&2, Maybe<&2, Lint.Def>, defs),
289        defs,
290        Lint.Program.callers(sources, defs, Set.from_list(program.unflat(sources, []))),
291        []
292      )
293    )
294  )

Uses (11)

Used by (1)