| ... |
... |
@@ -259,18 +259,30 @@ findImportedModuleNoHsc fc fopts ue home_module_name_providers_map mb_home_unit |
|
259
|
259
|
| uid <- sorted_deps
|
|
260
|
260
|
]
|
|
261
|
261
|
|
|
262
|
|
-sortHomeUnitsByLikelihoodFor :: HomeModuleNameProvidersMap -> ModuleName -> Set.Set UnitId -> [UnitId]
|
|
263
|
|
-sortHomeUnitsByLikelihoodFor _ _ hpt_deps | Set.null hpt_deps = []
|
|
|
262
|
+rankedHomeUnits :: HomeModuleNameProvidersMap
|
|
|
263
|
+ -> ModuleName
|
|
|
264
|
+ -> Set.Set UnitId
|
|
|
265
|
+ -> [UnitId]
|
|
|
266
|
+rankedHomeUnits _ _ hpt_deps | Set.null hpt_deps
|
|
|
267
|
+ = []
|
|
|
268
|
+rankedHomeUnits home_module_name_providers_map mod_name hpt_deps
|
|
|
269
|
+ = Set.toList cached_deps ++ Set.toList uncached_deps
|
|
|
270
|
+ where
|
|
|
271
|
+
|
|
|
272
|
+ cached_providers :: Set.Set UnitID
|
|
|
273
|
+ cached_providers = lookupWithDefaultUniqMap home_module_name_providers_map
|
|
|
274
|
+ Set.empty
|
|
|
275
|
+ mod_name
|
|
|
276
|
+
|
|
|
277
|
+ cached_deps :: Set.Set UnitID
|
|
|
278
|
+ cached_deps = Set.intersection hpt_deps cached_providers
|
|
|
279
|
+
|
|
|
280
|
+ uncached_deps :: Set.Set UnitID
|
|
|
281
|
+ uncached_deps = Set.difference hpt_deps cached_providers
|
|
264
|
282
|
{-
|
|
265
|
|
- With the above shortcut, evaluation of the module graph will not be
|
|
266
|
|
- triggered.
|
|
|
283
|
+ The special handling of the case that the dependency set is empty does not
|
|
|
284
|
+ change the result, but it avoids triggering evaluation of the module graph.
|
|
267
|
285
|
-}
|
|
268
|
|
-sortHomeUnitsByLikelihoodFor home_module_name_providers_map mod_name hpt_deps =
|
|
269
|
|
- let
|
|
270
|
|
- cached_module_providers = lookupWithDefaultUniqMap home_module_name_providers_map Set.empty mod_name
|
|
271
|
|
- cached_providing_deps = Set.toList (Set.intersection hpt_deps cached_module_providers)
|
|
272
|
|
- uncached_providing_deps = Set.toList (Set.difference hpt_deps cached_module_providers)
|
|
273
|
|
- in cached_providing_deps ++ uncached_providing_deps
|
|
274
|
286
|
|
|
275
|
287
|
-- | Locate a plugin module requested by the user, for a compiler
|
|
276
|
288
|
-- plugin. This consults the same set of exposed packages as
|