From a045a139763ab92f0f61ccdca8bba481db5f8b32 Mon Sep 17 00:00:00 2001 From: Jacob Sikorski Date: Fri, 20 Oct 2023 09:44:20 -0600 Subject: [PATCH] Fix brave/brave-ios#8292: Change the minimum number of engines available (brave/brave-ios#8288) --- .../WebFilters/ShieldStats/Adblock/AdBlockStats.swift | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Sources/Brave/WebFilters/ShieldStats/Adblock/AdBlockStats.swift b/Sources/Brave/WebFilters/ShieldStats/Adblock/AdBlockStats.swift index 1952e851e1b2..11df6cd27246 100644 --- a/Sources/Brave/WebFilters/ShieldStats/Adblock/AdBlockStats.swift +++ b/Sources/Brave/WebFilters/ShieldStats/Adblock/AdBlockStats.swift @@ -13,9 +13,12 @@ import os.log public actor AdBlockStats { /// The max number of enabled filter lists depending on the amount memory available to the device static var maxNumberOfAllowedFilterLists: Int = { - let memory = Int(ProcessInfo.processInfo.physicalMemory / 1073741824) - ContentBlockerManager.log.debug("Memory: \(memory)") - return min(5 * memory, 40) + // Get the number of gigs (memory in bytes divided by the size of a gig in bytes) + let numberOfGigs = Int(ProcessInfo.processInfo.physicalMemory / 1073741824) + ContentBlockerManager.log.debug("Number of gigs (rounded down): \(numberOfGigs)") + // Take a value between 20 and 40, + // with the real value somewhere in the middle depending on the device's memory + return max(min(5 * numberOfGigs, 40), 20) }() typealias CosmeticFilterModelTuple = (isAlwaysAggressive: Bool, model: CosmeticFilterModel)