def tally
bolt@1.27.0.0 · src/rules/perf/strings.bend:73
import bolt@1.27.0.0/src/rules/perf/strings.bend as Strings
import Base
import bolt@1.27.0.0/src/syntax/tree.bend as Tree
import bolt@1.27.0.0/src/rules/tokens.bend as T
73
74def tally(body: Tree.Node, +nn: U32, +chars: U32) -> Tally:
75 match body:
76 case Tree.NCons{Tree.Stmt{Tree.SCase{}, kids, b}, rest}:
77 +m = literal(T.pattern(kids))
78 +k = one(m)
79 +ch = size(m)
80 tally(rest, (nn + k : U32), (chars + ch : U32))
81 case Tree.NCons{h, rest}:
82 tally(rest, nn, chars)
83 case other:
84 Tally{nn, chars}