Wolfgang Jeltsch pushed to branch wip/jeltsch/more-efficient-home-unit-imports-finding at Glasgow Haskell Compiler / GHC

Commits:

1 changed file:

Changes:

  • compiler/GHC/Unit/Finder.hs
    ... ... @@ -252,32 +252,26 @@ findImportedModuleNoHsc fc fopts ue home_module_name_providers_map mb_home_unit
    252 252
         hpt_deps :: Set.Set UnitId
    
    253 253
         hpt_deps = homeUnitDepends units
    
    254 254
     
    
    255
    -    sorted_deps = sortHomeUnitsByLikelihoodFor home_module_name_providers_map mb_home_unit_id mod_name hpt_deps
    
    255
    +    sorted_deps = sortHomeUnitsByLikelihoodFor home_module_name_providers_map mod_name hpt_deps
    
    256 256
     
    
    257 257
         other_fopts =
    
    258 258
           [ (uid, initFinderOpts (homeUnitEnv_dflags (ue_findHomeUnitEnv uid ue)))
    
    259 259
           | uid <- sorted_deps
    
    260 260
           ]
    
    261 261
     
    
    262
    -sortHomeUnitsByLikelihoodFor :: HomeModuleNameProvidersMap -> Maybe UnitId -> ModuleName -> Set.Set UnitId -> [UnitId]
    
    263
    -sortHomeUnitsByLikelihoodFor _ _ _ hpt_deps | Set.null hpt_deps = []
    
    262
    +sortHomeUnitsByLikelihoodFor :: HomeModuleNameProvidersMap -> ModuleName -> Set.Set UnitId -> [UnitId]
    
    263
    +sortHomeUnitsByLikelihoodFor _ _ hpt_deps | Set.null hpt_deps = []
    
    264 264
     {-
    
    265 265
         With the above shortcut, evaluation of the module graph will not be
    
    266 266
         triggered.
    
    267 267
     -}
    
    268
    -sortHomeUnitsByLikelihoodFor home_module_name_providers_map mb_home_unit_id mod_name hpt_deps =
    
    268
    +sortHomeUnitsByLikelihoodFor home_module_name_providers_map mod_name hpt_deps =
    
    269 269
       let
    
    270 270
         cached_module_providers = lookupWithDefaultUniqMap home_module_name_providers_map Set.empty mod_name
    
    271
    -    cached_providing_deps = Set.intersection cached_module_providers hpt_deps
    
    272
    -    other_cached_providing_deps =
    
    273
    -      Set.toList $
    
    274
    -      maybe cached_providing_deps (\u -> Set.delete u cached_providing_deps) mb_home_unit_id
    
    275
    -    uncached_providing_deps =
    
    276
    -      let candidates = Set.difference hpt_deps cached_module_providers
    
    277
    -          excluded = maybe Set.empty Set.singleton mb_home_unit_id
    
    278
    -      in Set.toList (Set.difference candidates excluded)
    
    279
    -
    
    280
    -    all_deps = other_cached_providing_deps ++ uncached_providing_deps
    
    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
    +
    
    274
    +    all_deps = cached_providing_deps ++ uncached_providing_deps
    
    281 275
       in
    
    282 276
           assertPpr
    
    283 277
           (hpt_deps == Set.fromList all_deps)