def is_shallow

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

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

160# Whether two nodes, as written, are the same at their top: the same variable, literal or reference, or the same kind
161# of application, annotation or construction (their nodes below are compared next).
162def is_shallow(x: Lint.Node, y: Lint.Node) -> Bool:
163  match x y:
164    case Lint.Node{Lint.Variable{a}, n, s, k, f} Lint.Node{Lint.Variable{b}, m, r, j, g}:
165      U32.is_eq(a, b)
166    case Lint.Node{Lint.Literal{a}, n, s, k, f} Lint.Node{Lint.Literal{b}, m, r, j, g}:
167      String.eq(a, b) && String.eq(n, m)
168    case Lint.Node{Lint.Reference{a}, n, s, k, f} Lint.Node{Lint.Reference{b}, m, r, j, g}:
169      String.eq(a, b)
170    case Lint.Node{Lint.Application{}, n, s, k, f} Lint.Node{Lint.Application{}, m, r, j, g}:
171      True{}
172    case Lint.Node{Lint.Annotation{}, n, s, k, f} Lint.Node{Lint.Annotation{}, m, r, j, g}:
173      True{}
174    case Lint.Node{Lint.Construction{a}, n, s, k, f} Lint.Node{Lint.Construction{b}, m, r, j, g}:
175      String.eq(a, b)
176    case _ _:
177      False{}

Uses (6)

Used by (1)