1
1
mirror of https://github.com/github/semantic.git synced 2024-12-27 00:44:57 +03:00

Recur into Keyed nodes with equal keys.

This commit is contained in:
Rob Rix 2015-10-09 20:38:48 -04:00
parent 4a38090f4a
commit 48ce6b7a7f

View File

@ -93,6 +93,9 @@ public enum Algorithm<A, B> {
case let (.Indexed(a), .Indexed(b)) where a.count == b.count:
return f(.Indexed(zip(a, b).map(recur))).evaluate(equals, recur: recur)
case let (.Keyed(a), .Keyed(b)) where Array(a.keys) == Array(b.keys):
return f(.Keyed(Dictionary(elements: b.keys.map { ($0, recur(a[$0]!, b[$0]!)) }))).evaluate(equals, recur: recur)
default:
// This must not call `recur` with `a` and `b`, as that would infinite loop if actually recursive.
return f(Diff.Pure(.Replace(a, b))).evaluate(equals, recur: recur)