From 090e63b017069ce2dda9e555b2c5856eb9beeaf4 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sun, 9 Jul 2023 22:04:38 -0700 Subject: [PATCH] Replace uses of forEach with for-in loops. --- Mac/AppDelegate.swift | 4 +++- Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift | 8 ++++---- Mac/MainWindow/Timeline/TimelineViewController.swift | 6 +++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Mac/AppDelegate.swift b/Mac/AppDelegate.swift index 21364dbe6..cf3b42868 100644 --- a/Mac/AppDelegate.swift +++ b/Mac/AppDelegate.swift @@ -749,7 +749,9 @@ extension AppDelegate { @IBAction func debugDropConditionalGetInfo(_ sender: Any?) { #if DEBUG - AccountManager.shared.activeAccounts.forEach{ $0.debugDropConditionalGetInfo() } + for account in AccountManager.shared.activeAccounts { + account.debugDropConditionalGetInfo() + } #endif } diff --git a/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift b/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift index d0a26f28e..662c6f80b 100644 --- a/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift +++ b/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift @@ -370,14 +370,14 @@ private extension SidebarOutlineDataSource { return false } - draggedFeeds.forEach { pasteboardFeed in + for pasteboardFeed in draggedFeeds { guard let sourceAccountID = pasteboardFeed.accountID, let sourceAccount = AccountManager.shared.existingAccount(with: sourceAccountID), let feedID = pasteboardFeed.feedID, let feed = sourceAccount.existingFeed(withFeedID: feedID), let destinationContainer = parentNode.representedObject as? Container else { - return + continue } var sourceContainer: Container = sourceAccount // default to top level, @@ -475,14 +475,14 @@ private extension SidebarOutlineDataSource { return false } - draggedFolders.forEach { pasteboardFolder in + for pasteboardFolder in draggedFolders { guard let sourceAccountID = pasteboardFolder.accountID, let sourceAccount = AccountManager.shared.existingAccount(with: sourceAccountID), let folderStringID = pasteboardFolder.folderID, let folderID = Int(folderStringID), let folder = sourceAccount.existingFolder(withID: folderID) else { - return + continue } if !sameAccount(pasteboardFolder, parentNode) { copyFolderBetweenAccounts(folder: folder, to: parentNode) diff --git a/Mac/MainWindow/Timeline/TimelineViewController.swift b/Mac/MainWindow/Timeline/TimelineViewController.swift index ff7d2e73d..efe49661c 100644 --- a/Mac/MainWindow/Timeline/TimelineViewController.swift +++ b/Mac/MainWindow/Timeline/TimelineViewController.swift @@ -1139,7 +1139,7 @@ private extension TimelineViewController { func updateArticleRowMap() { var rowMap = [String: [Int]]() var index = 0 - articles.forEach { (article) in + for article in articles { if var indexes = rowMap[article.articleID] { indexes.append(index) rowMap[article.articleID] = indexes @@ -1160,9 +1160,9 @@ private extension TimelineViewController { func indexesForArticleIDs(_ articleIDs: Set) -> IndexSet { var indexes = IndexSet() - articleIDs.forEach { (articleID) in + for articleID in articleIDs { guard let rowsIndex = rows(for: articleID) else { - return + continue } for rowIndex in rowsIndex { indexes.insert(rowIndex)