diff --git a/Evergreen/FeedFinder/FeedSpecifier.swift b/Evergreen/FeedFinder/FeedSpecifier.swift index 268f464b2..02a17511e 100644 --- a/Evergreen/FeedFinder/FeedSpecifier.swift +++ b/Evergreen/FeedFinder/FeedSpecifier.swift @@ -23,7 +23,6 @@ public struct FeedSpecifier: Hashable { public let title: String? public let urlString: String public let source: Source - public let hashValue: Int public var score: Int { return calculatedScore() } @@ -33,12 +32,6 @@ public struct FeedSpecifier: Hashable { self.title = title self.urlString = urlString self.source = source - self.hashValue = urlString.hashValue - } - - public static func ==(lhs: FeedSpecifier, rhs: FeedSpecifier) -> Bool { - - return lhs.urlString == rhs.urlString && lhs.title == rhs.title && lhs.source == rhs.source } func feedSpecifierByMerging(_ feedSpecifier: FeedSpecifier) -> FeedSpecifier { @@ -73,6 +66,20 @@ public struct FeedSpecifier: Hashable { return currentBestFeed } + + // MARK: - Hashable + + public func hash(into hasher: inout Hasher) { + hasher.combine(urlString) + } + + // MARK: - Equatable + + public static func ==(lhs: FeedSpecifier, rhs: FeedSpecifier) -> Bool { + return lhs.urlString == rhs.urlString && lhs.title == rhs.title && lhs.source == rhs.source + } + + } private extension FeedSpecifier { diff --git a/Evergreen/FeedList/FeedListFeed.swift b/Evergreen/FeedList/FeedListFeed.swift index cb6839b7a..5032a0a5a 100644 --- a/Evergreen/FeedList/FeedListFeed.swift +++ b/Evergreen/FeedList/FeedListFeed.swift @@ -21,7 +21,6 @@ final class FeedListFeed: Hashable, DisplayNameProvider { let name: String let url: String let homePageURL: String - let hashValue: Int var lastDownloadAttemptDate: Date? = nil var parsedFeed: ParsedFeed? = nil { @@ -39,7 +38,6 @@ final class FeedListFeed: Hashable, DisplayNameProvider { self.name = name self.url = url self.homePageURL = homePageURL - self.hashValue = url.hashValue } private struct Key { @@ -73,9 +71,17 @@ final class FeedListFeed: Hashable, DisplayNameProvider { // } } + // MARK: - Hashable + + public func hash(into hasher: inout Hasher) { + hasher.combine(url) + } + + // MARK: - Equatable + static func ==(lhs: FeedListFeed, rhs: FeedListFeed) -> Bool { - return lhs.hashValue == rhs.hashValue && lhs.url == rhs.url && lhs.name == rhs.name && lhs.homePageURL == rhs.homePageURL + return lhs.url == rhs.url && lhs.name == rhs.name && lhs.homePageURL == rhs.homePageURL } } diff --git a/Evergreen/FeedList/FeedListFolder.swift b/Evergreen/FeedList/FeedListFolder.swift index 5a3689680..668292104 100644 --- a/Evergreen/FeedList/FeedListFolder.swift +++ b/Evergreen/FeedList/FeedListFolder.swift @@ -14,21 +14,25 @@ final class FeedListFolder: Hashable, DisplayNameProvider { let name: String let feeds: Set - let hashValue: Int var nameForDisplay: String { // DisplayNameProvider return name } init(name: String, feeds: Set) { - self.name = name self.feeds = feeds - self.hashValue = name.hashValue } - static func ==(lhs: FeedListFolder, rhs: FeedListFolder) -> Bool { + // MARK: - Hashable + public func hash(into hasher: inout Hasher) { + hasher.combine(name) + } + + // MARK: - Equatable + + static func ==(lhs: FeedListFolder, rhs: FeedListFolder) -> Bool { return lhs.name == rhs.name && lhs.feeds == rhs.feeds } } diff --git a/Evergreen/MainWindow/Timeline/Cell/MultilineTextFieldSizer.swift b/Evergreen/MainWindow/Timeline/Cell/MultilineTextFieldSizer.swift index 0f15b7676..a64b1f8c8 100644 --- a/Evergreen/MainWindow/Timeline/Cell/MultilineTextFieldSizer.swift +++ b/Evergreen/MainWindow/Timeline/Cell/MultilineTextFieldSizer.swift @@ -18,14 +18,21 @@ private struct TextFieldSizerSpecifier: Equatable, Hashable { let numberOfLines: Int let font: NSFont - let hashValue: Int init(numberOfLines: Int, font: NSFont) { self.numberOfLines = numberOfLines self.font = font - self.hashValue = font.hashValue ^ numberOfLines } + // MARK: - Hashable + + public func hash(into hasher: inout Hasher) { + hasher.combine(font) + hasher.combine(numberOfLines) + } + + // MARK: - Equatable + static func ==(lhs : TextFieldSizerSpecifier, rhs: TextFieldSizerSpecifier) -> Bool { return lhs.numberOfLines == rhs.numberOfLines && lhs.font == rhs.font