def is_same

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

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

179# Whether `xs` and `ys` are written the same way, node by node and below (if `ok`); `fuel` bounds the nodes compared.
180def is_same(+fuel: Nat, xs: List<&2, Lint.Node>, ys: List<&2, Lint.Node>, ok: Bool) -> Bool:
181  match fuel xs ys ok:
182    case _ _ _ False{}:
183      False{}
184    case _ Nil{} Nil{} True{}:
185      True{}
186    case 0n _ _ True{}:
187      False{}
188    case 1n+f Con{+x, xt} Con{+y, yt} True{}:
189      is_same(
190        f,
191        List.append(&2, Lint.Node, Lint.Node.kids(x), xt),
192        List.append(&2, Lint.Node, Lint.Node.kids(y), yt),
193        is_shallow(x, y)
194      )
195    case _ _ _ True{}:
196      False{}

Uses (7)

Used by (1)