1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 01:47:01 +03:00

Inline stream costs.

This commit is contained in:
Rob Rix 2015-11-12 15:58:14 -05:00
parent 17b9c0a9ec
commit 5253de2ef5

View File

@ -8,7 +8,7 @@ public func SES<Leaf, Annotation, C: CollectionType>(a: C, _ b: C, cost: Free<Le
if b.isEmpty { return a.map { .Delete($0) } }
func cons(diff: Diff, rest: Memo<Stream<(Diff, Int)>>) -> Stream<(Diff, Int)> {
return .Cons((diff, cost(diff) + costOfStream(rest)), rest)
return .Cons((diff, cost(diff) + (rest.value.first?.1 ?? 0)), rest)
}
func costOfStream(stream: Memo<Stream<(Diff, Int)>>) -> Int {