@@ -138,23 +138,19 @@ public struct ModulesGraph {
138
138
return self . rootPackages. contains ( id: package . id)
139
139
}
140
140
141
- private var modulesToPackages : [ ResolvedModule . ID : ResolvedPackage ]
142
-
143
141
/// Returns the package based on the given identity, or nil if the package isn't in the graph.
144
142
public func package ( for identity: PackageIdentity ) -> ResolvedPackage ? {
145
143
packages [ identity]
146
144
}
147
145
148
146
/// Returns the package that contains the module, or nil if the module isn't in the graph.
149
147
public func package ( for module: ResolvedModule ) -> ResolvedPackage ? {
150
- return self . modulesToPackages [ module. id ]
148
+ self . package ( for : module. packageIdentity )
151
149
}
152
150
153
-
154
- private var productsToPackages : [ ResolvedProduct . ID : ResolvedPackage ]
155
151
/// Returns the package that contains the product, or nil if the product isn't in the graph.
156
152
public func package ( for product: ResolvedProduct ) -> ResolvedPackage ? {
157
- return self . productsToPackages [ product. id ]
153
+ self . package ( for : product. packageIdentity )
158
154
}
159
155
160
156
/// Returns all of the packages that the given package depends on directly.
@@ -182,20 +178,6 @@ public struct ModulesGraph {
182
178
self . binaryArtifacts = binaryArtifacts
183
179
self . packages = packages
184
180
185
- // Create a mapping from targets to the packages that define them. Here
186
- // we include all targets, including tests in non-root packages, since
187
- // this is intended for lookup and not traversal.
188
- var modulesToPackages = self . packages. reduce ( into: [ : ] , { partial, package in
189
- package . targets. forEach { partial [ $0. id] = package }
190
- } )
191
-
192
- // Create a mapping from products to the packages that define them. Here
193
- // we include all products, including tests in non-root packages, since
194
- // this is intended for lookup and not traversal.
195
- var productsToPackages = packages. reduce ( into: [ : ] , { partial, package in
196
- package . products. forEach { partial [ $0. id] = package }
197
- } )
198
-
199
181
var allTargets = IdentifiableSet < ResolvedModule > ( )
200
182
var allProducts = IdentifiableSet < ResolvedProduct > ( )
201
183
for package in self . packages {
@@ -217,12 +199,8 @@ public struct ModulesGraph {
217
199
switch dependency {
218
200
case . target( let targetDependency, _) :
219
201
allTargets. insert ( targetDependency)
220
- modulesToPackages [ targetDependency. id] =
221
- self . packages [ targetDependency. packageIdentity]
222
202
case . product( let productDependency, _) :
223
203
allProducts. insert ( productDependency)
224
- productsToPackages [ productDependency. id] =
225
- self . packages [ productDependency. packageIdentity]
226
204
}
227
205
}
228
206
}
@@ -237,9 +215,6 @@ public struct ModulesGraph {
237
215
}
238
216
}
239
217
240
- self . modulesToPackages = modulesToPackages
241
- self . productsToPackages = productsToPackages
242
-
243
218
// Compute the reachable targets and products.
244
219
let inputTargets = self . inputPackages. flatMap { $0. targets }
245
220
let inputProducts = self . inputPackages. flatMap { $0. products }
@@ -274,17 +249,6 @@ public struct ModulesGraph {
274
249
product. buildTriple = buildTriple
275
250
return product
276
251
} )
277
-
278
- self . modulesToPackages = . init( self . modulesToPackages. map {
279
- var target = $0
280
- target. buildTriple = buildTriple
281
- return ( target, $1)
282
- } , uniquingKeysWith: { $1 } )
283
- self . productsToPackages = . init( self . productsToPackages. map {
284
- var product = $0
285
- product. buildTriple = buildTriple
286
- return ( product, $1)
287
- } , uniquingKeysWith: { $1 } )
288
252
}
289
253
290
254
/// Computes a map from each executable target in any of the root packages to the corresponding test targets.
0 commit comments