1
1
mirror of https://github.com/github/semantic.git synced 2024-12-26 08:25:19 +03:00

Switch through the term directly.

This commit is contained in:
Rob Rix 2015-11-12 17:46:18 -05:00
parent 4d3c335146
commit e7b1f59658

View File

@ -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) }
}
}