Improve performance of finding updated articles by improving performance of comparing articles by improving performance of comparing authors.

This commit is contained in:
Brent Simmons 2019-12-07 14:23:51 -08:00
parent b61cd3a869
commit ffaa630f34
1 changed files with 14 additions and 0 deletions

View File

@ -53,6 +53,20 @@ public struct Author: Codable, Hashable {
}
return nil
}
// MARK: - Hashable
public func hash(into hasher: inout Hasher) {
hasher.combine(authorID)
}
// MARK: - Equatable
static public func ==(lhs: Author, rhs: Author) -> Bool {
// The authorID is a calculation based on all the properties,
// and so its a quick shortcut to determine equality.
return lhs.authorID == rhs.authorID
}
}
extension Set where Element == Author {