Skip to content
This repository was archived by the owner on May 26, 2020. It is now read-only.

Commit 05d2fa1

Browse files
ikesyodmcrodrigues
authored andcommitted
Refactor == operator for Collection of Equatable (#10)
1 parent b3960bd commit 05d2fa1

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

Sources/Delta.swift

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,10 @@ extension Delta where Snapshot.Iterator.Element: Equatable, ChangeRepresentation
3131
fileprivate extension Collection where Iterator.Element: Equatable {
3232

3333
fileprivate static func ==(lhs: Self, rhs: Self) -> Bool {
34+
guard lhs.count == rhs.count else {
35+
return false
36+
}
3437

35-
guard lhs.count == rhs.count && lhs.count == rhs.count
36-
else { return false }
37-
38-
guard zip(lhs, rhs).map(==).reduce(true, { $0 && $1 })
39-
else { return false }
40-
41-
return true
38+
return zip(lhs, rhs).first(where: !=) == nil
4239
}
4340
}

0 commit comments

Comments
 (0)