Skip to content

Commit

Permalink
Remove unnecessary subtraction when calculating dependency ordering (#32
Browse files Browse the repository at this point in the history
)
  • Loading branch information
dfed authored Jan 21, 2024
1 parent db30891 commit 289130c
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions Sources/SafeDICore/Generators/ScopeGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -81,7 +80,6 @@ actor ScopeGenerator {
requiredReceivedProperties = [fulfillingProperty]
propertiesToGenerate = []
propertiesToDeclare = []
propertiesToFulfill = []
self.property = property
}

Expand Down Expand Up @@ -233,8 +231,6 @@ actor ScopeGenerator {
private let propertiesToGenerate: [ScopeGenerator]
/// Properties that this scope declares as a `let` constant.
private let propertiesToDeclare: Set<Property>
/// Properties that this scope declares as a `let` constant as well as properties this scope forwards as a closure argument.
private let propertiesToFulfill: Set<Property>
private let property: Property?

private var generateCodeTask: Task<String, Error>?
Expand Down

0 comments on commit 289130c

Please sign in to comment.