From 142774f5aeb2399f9845506f2ec31e21d9fe210b Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Thu, 27 Dec 2018 21:07:34 -0800 Subject: [PATCH] =?UTF-8?q?Use=20hash(into=E2=80=A6)=20instead=20of=20a=20?= =?UTF-8?q?hashValue=20instance=20variable.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frameworks/Articles/Article.swift | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Frameworks/Articles/Article.swift b/Frameworks/Articles/Article.swift index 32368f21c..17f9da9c7 100644 --- a/Frameworks/Articles/Article.swift +++ b/Frameworks/Articles/Article.swift @@ -27,10 +27,7 @@ public struct Article: Hashable { public let authors: Set? public let attachments: Set? public let status: ArticleStatus - public var hashValue: Int { - return articleID.hashValue - } - + public init(accountID: String, articleID: String?, feedID: String, uniqueID: String, title: String?, contentHTML: String?, contentText: String?, url: String?, externalURL: String?, summary: String?, imageURL: String?, bannerImageURL: String?, datePublished: Date?, dateModified: Date?, authors: Set?, attachments: Set?, status: ArticleStatus) { self.accountID = accountID @@ -59,20 +56,23 @@ public struct Article: Hashable { } public static func calculatedArticleID(feedID: String, uniqueID: String) -> String { - return databaseIDWithString("\(feedID) \(uniqueID)") } + + // MARK: - Hashable + + public func hash(into hasher: inout Hasher) { + hasher.combine(articleID) + } } public extension Set where Element == Article { public func articleIDs() -> Set { - return Set(map { $0.articleID }) } public func unreadArticles() -> Set
{ - let articles = self.filter { !$0.status.read } return Set(articles) } @@ -80,8 +80,7 @@ public extension Set where Element == Article { public extension Array where Element == Article { - public func articleIDs() -> [String] { - + public func articleIDs() -> [String] { return map { $0.articleID } } }