mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-12-01 09:50:16 +00:00
Avoid some set/array/set roundtrips.
This commit is contained in:
1 parent
c2fda87e1b
commit
e085bdf138
3 files changed
+8
-17
No files matched your search
@@ -72,17 +72,10 @@ import Articles
|
||||
|
||||
public var authors: Set<Author>? {
|
||||
get {
|
||||
if let authorsArray = settings.authors {
|
||||
return Set(authorsArray)
|
||||
}
|
||||
return nil
|
||||
settings.authors
|
||||
}
|
||||
set {
|
||||
if let authorsSet = newValue {
|
||||
settings.authors = Array(authorsSet)
|
||||
} else {
|
||||
settings.authors = nil
|
||||
}
|
||||
settings.authors = newValue
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ import Articles
|
||||
}
|
||||
}
|
||||
|
||||
var authors: [Author]? {
|
||||
var authors: Set<Author>? {
|
||||
didSet {
|
||||
if authors != oldValue {
|
||||
database.setAuthors(authors, for: feedURL)
|
||||
|
||||
@@ -43,7 +43,7 @@ final class FeedSettingsDatabase: Sendable {
|
||||
let contentHash: String?
|
||||
let newArticleNotificationsEnabled: Bool
|
||||
let readerViewAlwaysEnabled: Bool
|
||||
let authors: [Author]?
|
||||
let authors: Set<Author>?
|
||||
let conditionalGetInfo: HTTPConditionalGetInfo?
|
||||
let conditionalGetInfoDate: Date?
|
||||
let cacheControlInfo: CacheControlInfo?
|
||||
@@ -212,10 +212,10 @@ final class FeedSettingsDatabase: Sendable {
|
||||
}
|
||||
}
|
||||
|
||||
func setAuthors(_ authors: [Author]?, for feedURL: String) {
|
||||
func setAuthors(_ authors: Set<Author>?, for feedURL: String) {
|
||||
serialDispatchQueue.async {
|
||||
if let authors {
|
||||
let jsonString = Set(authors).json()
|
||||
let jsonString = authors.json()
|
||||
self.database.executeUpdate("UPDATE feedSettings SET authors = ? WHERE feedURL = ?;", withArgumentsIn: [jsonString as Any, feedURL])
|
||||
} else {
|
||||
self.database.executeUpdate("UPDATE feedSettings SET authors = NULL WHERE feedURL = ?;", withArgumentsIn: [feedURL])
|
||||
@@ -290,11 +290,9 @@ private extension FeedSettingsDatabase {
|
||||
cacheControlInfo = CacheControlInfo(dateCreated: dateCreated, maxAge: maxAge)
|
||||
}
|
||||
|
||||
var authors: [Author]?
|
||||
var authors: Set<Author>?
|
||||
if let authorsData = resultSet.data(forColumn: Column.authors.rawValue) {
|
||||
if let authorsSet = Author.authorsWithJSON(authorsData) {
|
||||
authors = Array(authorsSet)
|
||||
}
|
||||
authors = Author.authorsWithJSON(authorsData)
|
||||
}
|
||||
|
||||
var folderRelationship: [String: String]?
|
||||
|
||||
Reference in new issue
Block a user