Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Use mutable reduce
Browse files Browse the repository at this point in the history
  • Loading branch information
cuba committed Oct 11, 2023
1 parent 49f4e94 commit 8367076
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions Sources/Brave/Frontend/Browser/Helpers/LaunchHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,18 @@ private extension FilterListStorage {
/// Return all the blocklist types that are valid for filter lists.
var validBlocklistTypes: Set<ContentBlockerManager.BlocklistType> {
if filterLists.isEmpty {
/// If we don't have filter lists yet loaded, use the settings
return allFilterListSettings.reduce(Set<ContentBlockerManager.BlocklistType>()) { partialResult, setting in
guard let componentId = setting.componentId else { return partialResult }
return partialResult.union([
// If we don't have filter lists yet loaded, use the settings
return allFilterListSettings.reduce(into: Set<ContentBlockerManager.BlocklistType>(), { partialResult, setting in
guard let componentId = setting.componentId else { return }

partialResult.formUnion([
.filterList(componentId: componentId, isAlwaysAggressive: setting.isAlwaysAggressive)
])
}
})
} else {
/// If we do have filter lists yet loaded, use them as they are always the most up to date and accurate
return filterLists.reduce(Set<ContentBlockerManager.BlocklistType>()) { partialResult, filterList in
return partialResult.union([
// If we do have filter lists yet loaded, use them as they are always the most up to date and accurate
return filterLists.reduce(into: Set<ContentBlockerManager.BlocklistType>()) { partialResult, filterList in
partialResult.formUnion([
.filterList(componentId: filterList.entry.componentId, isAlwaysAggressive: filterList.isAlwaysAggressive)
])
}
Expand Down

0 comments on commit 8367076

Please sign in to comment.