Make Article a class, which boosts performance by not having to init/destroy Article all time.
This commit is contained in:
parent
7689326d56
commit
75e525380b
@ -10,7 +10,7 @@ import Foundation
|
||||
|
||||
public typealias ArticleSetBlock = (Set<Article>) -> Void
|
||||
|
||||
public struct Article: Hashable, Sendable {
|
||||
public final class Article: Hashable, Sendable {
|
||||
|
||||
public let articleID: String // Unique database ID (possibly sync service ID)
|
||||
public let accountID: String
|
||||
@ -83,7 +83,6 @@ public extension Set where Element == Article {
|
||||
func contains(accountID: String, articleID: String) -> Bool {
|
||||
return contains(where: { $0.accountID == accountID && $0.articleID == articleID})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public extension Array where Element == Article {
|
||||
|
@ -14,7 +14,7 @@ import FMDB
|
||||
|
||||
extension Article {
|
||||
|
||||
init?(accountID: String, row: FMResultSet, status: ArticleStatus) {
|
||||
convenience init?(accountID: String, row: FMResultSet, status: ArticleStatus) {
|
||||
guard let articleID = row.string(forColumn: DatabaseKey.articleID) else {
|
||||
assertionFailure("Expected articleID.")
|
||||
return nil
|
||||
@ -41,7 +41,7 @@ extension Article {
|
||||
self.init(accountID: accountID, articleID: articleID, feedID: feedID, uniqueID: uniqueID, title: title, contentHTML: contentHTML, contentText: contentText, url: url, externalURL: externalURL, summary: summary, imageURL: imageURL, datePublished: datePublished, dateModified: dateModified, authors: nil, status: status)
|
||||
}
|
||||
|
||||
init(parsedItem: ParsedItem, maximumDateAllowed: Date, accountID: String, feedID: String, status: ArticleStatus) {
|
||||
convenience init(parsedItem: ParsedItem, maximumDateAllowed: Date, accountID: String, feedID: String, status: ArticleStatus) {
|
||||
let authors = Author.authorsWithParsedAuthors(parsedItem.authors)
|
||||
|
||||
// Deal with future datePublished and dateModified dates.
|
||||
|
Loading…
x
Reference in New Issue
Block a user