[Git][ghc/ghc][wip/jeltsch/more-efficient-home-unit-imports-finding] Polish the code for home module ranking
Wolfgang Jeltsch pushed to branch wip/jeltsch/more-efficient-home-unit-imports-finding at Glasgow Haskell Compiler / GHC Commits: 54eb5564 by Wolfgang Jeltsch at 2026-04-29T13:56:48+03:00 Polish the code for home module ranking - - - - - 1 changed file: - compiler/GHC/Unit/Finder.hs Changes: ===================================== compiler/GHC/Unit/Finder.hs ===================================== @@ -259,18 +259,30 @@ findImportedModuleNoHsc fc fopts ue home_module_name_providers_map mb_home_unit | uid <- sorted_deps ] -sortHomeUnitsByLikelihoodFor :: HomeModuleNameProvidersMap -> ModuleName -> Set.Set UnitId -> [UnitId] -sortHomeUnitsByLikelihoodFor _ _ hpt_deps | Set.null hpt_deps = [] +rankedHomeUnits :: HomeModuleNameProvidersMap + -> ModuleName + -> Set.Set UnitId + -> [UnitId] +rankedHomeUnits _ _ hpt_deps | Set.null hpt_deps + = [] +rankedHomeUnits home_module_name_providers_map mod_name hpt_deps + = Set.toList cached_deps ++ Set.toList uncached_deps + where + + cached_providers :: Set.Set UnitID + cached_providers = lookupWithDefaultUniqMap home_module_name_providers_map + Set.empty + mod_name + + cached_deps :: Set.Set UnitID + cached_deps = Set.intersection hpt_deps cached_providers + + uncached_deps :: Set.Set UnitID + uncached_deps = Set.difference hpt_deps cached_providers {- - With the above shortcut, evaluation of the module graph will not be - triggered. + The special handling of the case that the dependency set is empty does not + change the result, but it avoids triggering evaluation of the module graph. -} -sortHomeUnitsByLikelihoodFor home_module_name_providers_map mod_name hpt_deps = - let - cached_module_providers = lookupWithDefaultUniqMap home_module_name_providers_map Set.empty mod_name - cached_providing_deps = Set.toList (Set.intersection hpt_deps cached_module_providers) - uncached_providing_deps = Set.toList (Set.difference hpt_deps cached_module_providers) - in cached_providing_deps ++ uncached_providing_deps -- | Locate a plugin module requested by the user, for a compiler -- plugin. This consults the same set of exposed packages as View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/54eb5564af32c490e9493d966c67be09... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/54eb5564af32c490e9493d966c67be09... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Wolfgang Jeltsch (@jeltsch)