From e085bdf13803a48a4ca83a11f646ee5bf850dce7 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Mon, 22 Jun 2026 12:00:20 -0700 Subject: [PATCH] Avoid some set/array/set roundtrips. --- Modules/Account/Sources/Account/Feed.swift | 11 ++--------- Modules/Account/Sources/Account/FeedSettings.swift | 2 +- .../Sources/Account/FeedSettingsDatabase.swift | 12 +++++------- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/Modules/Account/Sources/Account/Feed.swift b/Modules/Account/Sources/Account/Feed.swift index 9a085913c..b1b9ebda5 100644 --- a/Modules/Account/Sources/Account/Feed.swift +++ b/Modules/Account/Sources/Account/Feed.swift @@ -72,17 +72,10 @@ import Articles public var authors: Set? { 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 } } diff --git a/Modules/Account/Sources/Account/FeedSettings.swift b/Modules/Account/Sources/Account/FeedSettings.swift index 8a583638b..7ff5d53f0 100644 --- a/Modules/Account/Sources/Account/FeedSettings.swift +++ b/Modules/Account/Sources/Account/FeedSettings.swift @@ -78,7 +78,7 @@ import Articles } } - var authors: [Author]? { + var authors: Set? { didSet { if authors != oldValue { database.setAuthors(authors, for: feedURL) diff --git a/Modules/Account/Sources/Account/FeedSettingsDatabase.swift b/Modules/Account/Sources/Account/FeedSettingsDatabase.swift index d2703293e..df15aed85 100644 --- a/Modules/Account/Sources/Account/FeedSettingsDatabase.swift +++ b/Modules/Account/Sources/Account/FeedSettingsDatabase.swift @@ -43,7 +43,7 @@ final class FeedSettingsDatabase: Sendable { let contentHash: String? let newArticleNotificationsEnabled: Bool let readerViewAlwaysEnabled: Bool - let authors: [Author]? + let authors: Set? 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?, 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? 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]?