@@ -83,13 +83,14 @@ extension ModuleDependencyGraph {
8383// MARK: - Getting a graph read from priors ready to use
8484extension ModuleDependencyGraph {
8585 func collectNodesInvalidatedByChangedOrAddedExternals( ) -> Set < Node > {
86- let invalidatedNodes = fingerprintedExternalDependencies. lazy. flatMap {
87- self . collectNodesInvalidatedByProcessing ( fingerprintedExternalDependency: $0,
88- includeAddedExternals: true )
86+ fingerprintedExternalDependencies. reduce ( into: Set ( ) ) { invalidatedNodes, fed in
87+ invalidatedNodes. formUnion (
88+ self . collectNodesInvalidatedByProcessing ( fingerprintedExternalDependency: fed,
89+ includeAddedExternals: true ) )
8990 }
90- return Set ( invalidatedNodes)
9191 }
9292}
93+
9394// MARK: - Scheduling the first wave
9495extension ModuleDependencyGraph {
9596 /// Find all the sources that depend on `sourceFile`. For some source files, these will be
@@ -179,11 +180,13 @@ extension ModuleDependencyGraph {
179180 in: self ,
180181 diagnosticEngine: info. diagnosticEngine)
181182 . tracedUses
182- let invalidatedSources = Set (
183- affectedNodes. compactMap {
184- $0. dependencySource. flatMap { $0. typedFile. type == . swiftDeps ? $0 : nil }
185- } )
186- return invalidatedSources
183+ return affectedNodes. reduce ( into: Set ( ) ) {
184+ invalidatedSources, affectedNode in
185+ if let source = affectedNode. dependencySource,
186+ source. typedFile. type == . swiftDeps {
187+ invalidatedSources. insert ( source)
188+ }
189+ }
187190 }
188191
189192 /// Given an external dependency & its fingerprint, find any nodes directly using that dependency.
@@ -248,10 +251,10 @@ extension ModuleDependencyGraph {
248251 func collectInputsUsingTransitivelyInvalidated(
249252 nodes invalidatedNodes: Set < Node >
250253 ) -> Set < TypedVirtualPath > {
251- let invalidatedInputs =
252- collectSwiftDepsUsingTransitivelyInvalidated ( nodes : invalidatedNodes ) . lazy
253- . map ( getInput ( for: ) )
254- return Set ( invalidatedInputs )
254+ collectSwiftDepsUsingTransitivelyInvalidated ( nodes : invalidatedNodes )
255+ . reduce ( into : Set ( ) ) { invalidatedInputs , invalidatedSwiftDeps in
256+ invalidatedInputs . insert ( getInput ( for: invalidatedSwiftDeps ) )
257+ }
255258 }
256259}
257260
0 commit comments