From 19d7203d0c44dc4061b20108ed5bba78b98e0723 Mon Sep 17 00:00:00 2001 From: Bartek Waresiak Date: Tue, 5 Nov 2024 10:28:51 +0100 Subject: [PATCH] Preserve the calling order when returning data --- .../AdClickAttribution/AdClickAttributionRulesProvider.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/BrowserServicesKit/ContentBlocking/AdClickAttribution/AdClickAttributionRulesProvider.swift b/Sources/BrowserServicesKit/ContentBlocking/AdClickAttribution/AdClickAttributionRulesProvider.swift index 3bcf1764d..36f5893ce 100644 --- a/Sources/BrowserServicesKit/ContentBlocking/AdClickAttribution/AdClickAttributionRulesProvider.swift +++ b/Sources/BrowserServicesKit/ContentBlocking/AdClickAttribution/AdClickAttributionRulesProvider.swift @@ -155,7 +155,9 @@ public class AdClickAttributionRulesProvider: AdClickAttributionRulesProviding { // This is optimization: in case multiple tabs request same attribution at the same time, we will respond quickly. var matchingTasks = tasks.filter { $0 == attributionTask } tasks.removeAll(where: { $0 == attributionTask }) - matchingTasks.append(attributionTask) + + // Preserve order in which rules were requested + matchingTasks.insert(attributionTask, at: 0) Logger.contentBlocking.debug("Returning attribution rules for vendor \(attributionTask.vendor) to \(matchingTasks.count, privacy: .public) caller(s)")