mirror of
https://github.com/github/semantic.git
synced 2024-11-24 08:54:07 +03:00
Switch through the term directly.
This commit is contained in:
parent
4d3c335146
commit
e7b1f59658
@ -208,14 +208,14 @@ extension Cofree {
|
||||
///
|
||||
/// This is used to compute the cost of patches, such that a patch inserting a very large tree will be charged approximately the same as a very large tree consisting of many small patches.
|
||||
public static func size(term: Cofree) -> Int {
|
||||
switch term.unwrap {
|
||||
case .Leaf:
|
||||
switch term {
|
||||
case .Unroll(_, .Leaf):
|
||||
return 1
|
||||
case let .Indexed(a):
|
||||
case let .Unroll(_, .Indexed(a)):
|
||||
return a.reduce(0) { $0 + size($1) }
|
||||
case let .Fixed(a):
|
||||
case let .Unroll(_, .Fixed(a)):
|
||||
return a.reduce(0) { $0 + size($1) }
|
||||
case let .Keyed(a):
|
||||
case let .Unroll(_, .Keyed(a)):
|
||||
return a.reduce(0) { $0 + size($1.1) }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user