Replace uses of forEach with for-in loops.

This commit is contained in:
Brent Simmons
2023-07-09 22:24:50 -07:00
parent d60c2f6b60
commit d3d718c1b0
4 changed files with 13 additions and 11 deletions

View File

@@ -92,7 +92,7 @@ final class FeedlyCreateFeedsForCollectionFoldersOperation: FeedlyOperation, Log
}
logger.debug("Processing \(feedsAndFolders.count, privacy: .public) feeds.")
feedsAndFolders.forEach { (feed, folder) in
for (feed, folder) in feedsAndFolders {
if !folder.has(feed) {
folder.addFeed(feed)
}

View File

@@ -22,13 +22,13 @@ final class OPMLNormalizer {
private func normalize(_ items: [RSOPMLItem], parentFolder: RSOPMLItem? = nil) {
var feedsToAdd = [RSOPMLItem]()
items.forEach { (item) in
for item in items {
if let _ = item.feedSpecifier {
if !feedsToAdd.contains(where: { $0.feedSpecifier?.feedURL == item.feedSpecifier?.feedURL }) {
feedsToAdd.append(item)
}
return
continue
}
guard let _ = item.titleFromAttributes else {
@@ -36,7 +36,7 @@ final class OPMLNormalizer {
if let itemChildren = item.children {
normalize(itemChildren, parentFolder: parentFolder)
}
return
continue
}
feedsToAdd.append(item)

View File

@@ -716,7 +716,7 @@ private extension ReaderAPIAccountDelegate {
// Delete any folders not at Reader
if let folders = account.folders {
folders.forEach { folder in
for folder in folders {
if !readerFolderExternalIDs.contains(folder.externalID ?? "") {
for feed in folder.topLevelFeeds {
account.addFeed(feed)
@@ -736,7 +736,7 @@ private extension ReaderAPIAccountDelegate {
}()
// Make any folders Reader has, but we don't
folderTags.forEach { tag in
for tag in folderTags {
if !folderExternalIDs.contains(tag.tagID) {
let folder = account.ensureFolder(with: tag.folderName ?? "None")
folder?.externalID = tag.tagID
@@ -773,7 +773,7 @@ private extension ReaderAPIAccountDelegate {
}
// Add any feeds we don't have and update any we do
subscriptions.forEach { subscription in
for subscription in subscriptions {
if let feed = account.existingFeed(withFeedID: subscription.feedID) {
feed.name = subscription.name
@@ -799,14 +799,14 @@ private extension ReaderAPIAccountDelegate {
let taggingsDict = subscriptions.reduce([String: [ReaderAPISubscription]]()) { (dict, subscription) in
var taggedFeeds = dict
subscription.categories.forEach({ (category) in
for category in subscription.categories {
if var taggedFeed = taggedFeeds[category.categoryId] {
taggedFeed.append(subscription)
taggedFeeds[category.categoryId] = taggedFeed
} else {
taggedFeeds[category.categoryId] = [subscription]
}
})
}
return taggedFeeds
}

View File

@@ -132,7 +132,9 @@ final class SearchTable: DatabaseTable {
private extension SearchTable {
func performInitialIndexForArticles(_ articles: Set<ArticleSearchInfo>, _ database: FMDatabase) {
articles.forEach { performInitialIndex($0, database) }
for article in articles {
performInitialIndex(article, database)
}
}
func performInitialIndex(_ article: ArticleSearchInfo, _ database: FMDatabase) {
@@ -177,7 +179,7 @@ private extension SearchTable {
let groupedSearchInfos = Dictionary(grouping: searchInfos, by: { $0.rowID })
let searchInfosDictionary = groupedSearchInfos.mapValues { $0.first! }
articles.forEach { (article) in
for article in articles {
updateIndexForArticle(article, searchInfosDictionary, database)
}
}