From 2ac4df4ee6fe974255e30fde9cbc0dba770ed900 Mon Sep 17 00:00:00 2001 From: Nate Weaver Date: Sat, 8 Feb 2020 17:46:48 -0600 Subject: [PATCH] Use a single compactMap() instead of filter().compactMap() --- Shared/Favicons/FaviconURLFinder.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Shared/Favicons/FaviconURLFinder.swift b/Shared/Favicons/FaviconURLFinder.swift index 54f38606b..cc429e4c6 100644 --- a/Shared/Favicons/FaviconURLFinder.swift +++ b/Shared/Favicons/FaviconURLFinder.swift @@ -49,20 +49,20 @@ struct FaviconURLFinder { // If the favicon has an explicit type, check that for an ignored type; otherwise, check the file extension. HTMLMetadataDownloader.downloadMetadata(for: homePageURL) { (htmlMetadata) in - let faviconURLs = htmlMetadata?.favicons.filter({ (favicon) -> Bool in + let faviconURLs = htmlMetadata?.favicons.compactMap({ (favicon) -> String? in if let type = favicon.type { if ignoredMimeTypes.contains(type) { - return false + return nil } } else { if let urlString = favicon.urlString, let url = URL(string: urlString), ignoredExtensions.contains(url.pathExtension) { - return false + return nil } } - return true - }).compactMap { $0.urlString } + return favicon.urlString + }) completion(faviconURLs) }