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 b49f1f6
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Sources/Brave/Frontend/Browser/Helpers/LaunchHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,17 @@ private extension FilterListStorage {
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([
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([
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 b49f1f6

Please sign in to comment.