From 289130ceef221bc8d6c816cec5eded4aa4032475 Mon Sep 17 00:00:00 2001 From: Dan Federman Date: Sat, 20 Jan 2024 18:34:15 -0800 Subject: [PATCH] Remove unnecessary subtraction when calculating dependency ordering (#32) --- Sources/SafeDICore/Generators/ScopeGenerator.swift | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/Sources/SafeDICore/Generators/ScopeGenerator.swift b/Sources/SafeDICore/Generators/ScopeGenerator.swift index 4eac45ef..00e78c5f 100644 --- a/Sources/SafeDICore/Generators/ScopeGenerator.swift +++ b/Sources/SafeDICore/Generators/ScopeGenerator.swift @@ -45,15 +45,14 @@ actor ScopeGenerator { self.property = property self.propertiesToGenerate = propertiesToGenerate propertiesToDeclare = Set(propertiesToGenerate.compactMap(\.property)) - propertiesToFulfill = propertiesToDeclare.union(scopeData.forwardedProperties) requiredReceivedProperties = Set( - propertiesToGenerate.flatMap { [propertiesToFulfill] propertyToGenerate in + propertiesToGenerate.flatMap { [propertiesToDeclare, scopeData] propertyToGenerate in // All the properties this child and its children require be passed in. propertyToGenerate.requiredReceivedProperties - // Minus all the properties this child fulfills for themselves. - .subtracting(propertyToGenerate.propertiesToFulfill) - // Minus all the properties we fulfill. - .subtracting(propertiesToFulfill) + // Minus the properties we declare. + .subtracting(propertiesToDeclare) + // Minus the properties we forward. + .subtracting(scopeData.forwardedProperties) } ) // Unioned with the properties we require to fulfill our own dependencies. @@ -81,7 +80,6 @@ actor ScopeGenerator { requiredReceivedProperties = [fulfillingProperty] propertiesToGenerate = [] propertiesToDeclare = [] - propertiesToFulfill = [] self.property = property } @@ -233,8 +231,6 @@ actor ScopeGenerator { private let propertiesToGenerate: [ScopeGenerator] /// Properties that this scope declares as a `let` constant. private let propertiesToDeclare: Set - /// Properties that this scope declares as a `let` constant as well as properties this scope forwards as a closure argument. - private let propertiesToFulfill: Set private let property: Property? private var generateCodeTask: Task?