Use new hash-into instead of hashValue. WIP on #402.
This commit is contained in:
parent
d274b4eac1
commit
fdf767865a
@ -23,7 +23,6 @@ public struct FeedSpecifier: Hashable {
|
|||||||
public let title: String?
|
public let title: String?
|
||||||
public let urlString: String
|
public let urlString: String
|
||||||
public let source: Source
|
public let source: Source
|
||||||
public let hashValue: Int
|
|
||||||
public var score: Int {
|
public var score: Int {
|
||||||
return calculatedScore()
|
return calculatedScore()
|
||||||
}
|
}
|
||||||
@ -33,12 +32,6 @@ public struct FeedSpecifier: Hashable {
|
|||||||
self.title = title
|
self.title = title
|
||||||
self.urlString = urlString
|
self.urlString = urlString
|
||||||
self.source = source
|
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 {
|
func feedSpecifierByMerging(_ feedSpecifier: FeedSpecifier) -> FeedSpecifier {
|
||||||
@ -73,6 +66,20 @@ public struct FeedSpecifier: Hashable {
|
|||||||
|
|
||||||
return currentBestFeed
|
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 {
|
private extension FeedSpecifier {
|
||||||
|
@ -21,7 +21,6 @@ final class FeedListFeed: Hashable, DisplayNameProvider {
|
|||||||
let name: String
|
let name: String
|
||||||
let url: String
|
let url: String
|
||||||
let homePageURL: String
|
let homePageURL: String
|
||||||
let hashValue: Int
|
|
||||||
var lastDownloadAttemptDate: Date? = nil
|
var lastDownloadAttemptDate: Date? = nil
|
||||||
|
|
||||||
var parsedFeed: ParsedFeed? = nil {
|
var parsedFeed: ParsedFeed? = nil {
|
||||||
@ -39,7 +38,6 @@ final class FeedListFeed: Hashable, DisplayNameProvider {
|
|||||||
self.name = name
|
self.name = name
|
||||||
self.url = url
|
self.url = url
|
||||||
self.homePageURL = homePageURL
|
self.homePageURL = homePageURL
|
||||||
self.hashValue = url.hashValue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private struct Key {
|
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 {
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,21 +14,25 @@ final class FeedListFolder: Hashable, DisplayNameProvider {
|
|||||||
|
|
||||||
let name: String
|
let name: String
|
||||||
let feeds: Set<FeedListFeed>
|
let feeds: Set<FeedListFeed>
|
||||||
let hashValue: Int
|
|
||||||
|
|
||||||
var nameForDisplay: String { // DisplayNameProvider
|
var nameForDisplay: String { // DisplayNameProvider
|
||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
|
|
||||||
init(name: String, feeds: Set<FeedListFeed>) {
|
init(name: String, feeds: Set<FeedListFeed>) {
|
||||||
|
|
||||||
self.name = name
|
self.name = name
|
||||||
self.feeds = feeds
|
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
|
return lhs.name == rhs.name && lhs.feeds == rhs.feeds
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,14 +18,21 @@ private struct TextFieldSizerSpecifier: Equatable, Hashable {
|
|||||||
|
|
||||||
let numberOfLines: Int
|
let numberOfLines: Int
|
||||||
let font: NSFont
|
let font: NSFont
|
||||||
let hashValue: Int
|
|
||||||
|
|
||||||
init(numberOfLines: Int, font: NSFont) {
|
init(numberOfLines: Int, font: NSFont) {
|
||||||
self.numberOfLines = numberOfLines
|
self.numberOfLines = numberOfLines
|
||||||
self.font = font
|
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 {
|
static func ==(lhs : TextFieldSizerSpecifier, rhs: TextFieldSizerSpecifier) -> Bool {
|
||||||
|
|
||||||
return lhs.numberOfLines == rhs.numberOfLines && lhs.font == rhs.font
|
return lhs.numberOfLines == rhs.numberOfLines && lhs.font == rhs.font
|
||||||
|
Loading…
x
Reference in New Issue
Block a user