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

Commits:

1 changed file:

Changes:

  • compiler/GHC/Unit/Finder.hs
    ... ... @@ -206,7 +206,7 @@ findImportedModuleNoHsc fc fopts ue home_module_map mhome_unit mod_name mb_pkg =
    206 206
       case mb_pkg of
    
    207 207
         NoPkgQual  -> unqual_import
    
    208 208
         ThisPkg uid | (homeUnitId <$> mhome_unit) == Just uid -> home_import
    
    209
    -                | Just os <- M.lookup uid other_fopts_map -> home_pkg_import (uid, os)
    
    209
    +                | Just os <- lookup uid other_fopts -> home_pkg_import (uid, os)
    
    210 210
                     | otherwise -> pprPanic "findImportModule" (ppr mod_name $$ ppr mb_pkg $$ ppr (homeUnitId <$> mhome_unit) $$ ppr uid $$ ppr (map fst all_opts))
    
    211 211
         OtherPkg _ -> pkg_import
    
    212 212
       where
    
    ... ... @@ -214,10 +214,8 @@ findImportedModuleNoHsc fc fopts ue home_module_map mhome_unit mod_name mb_pkg =
    214 214
         module_home_units = M.findWithDefault Set.empty mod_name module_name_map
    
    215 215
         current_unit_id = homeUnitId <$> mhome_unit
    
    216 216
         all_opts = case current_unit_id of
    
    217
    -                Nothing -> other_fopts_list
    
    218
    -                Just home_unit_id -> (home_unit_id, fopts) : other_fopts_list
    
    219
    -
    
    220
    -    other_fopts_map = M.fromList other_fopts_list
    
    217
    +                Nothing -> other_fopts
    
    218
    +                Just home_unit_id -> (home_unit_id, fopts) : other_fopts
    
    221 219
     
    
    222 220
         home_import = case mhome_unit of
    
    223 221
                        Just home_unit -> findHomeModule fc fopts home_unit mod_name
    
    ... ... @@ -237,7 +235,7 @@ findImportedModuleNoHsc fc fopts ue home_module_map mhome_unit mod_name mb_pkg =
    237 235
         -- Do not be smart and change this to `foldr orIfNotFound home_import hs` as
    
    238 236
         -- that is not the same!! home_import is first because we need to look within ourselves
    
    239 237
         -- first before looking at the packages in order.
    
    240
    -    any_home_import = foldr1 orIfNotFound (home_import :| map home_pkg_import other_fopts_list)
    
    238
    +    any_home_import = foldr1 orIfNotFound (home_import :| map home_pkg_import other_fopts)
    
    241 239
     
    
    242 240
         pkg_import    = findExposedPackageModule fc fopts units  mod_name mb_pkg
    
    243 241
     
    
    ... ... @@ -259,7 +257,7 @@ findImportedModuleNoHsc fc fopts ue home_module_map mhome_unit mod_name mb_pkg =
    259 257
               excluded = maybe Set.empty Set.singleton {- maybe dep_providers (\u -> Set.insert u dep_providers) -} current_unit_id
    
    260 258
           in Set.toList (Set.difference candidates excluded)
    
    261 259
         other_home_uids = known_other_uids ++ unknown_units
    
    262
    -    other_fopts_list =
    
    260
    +    other_fopts =
    
    263 261
           [ (uid, initFinderOpts (homeUnitEnv_dflags (ue_findHomeUnitEnv uid ue)))
    
    264 262
           | uid <- other_home_uids
    
    265 263
           ]