Wolfgang Jeltsch pushed to branch wip/jeltsch/more-efficient-home-unit-imports-finding.jeltsch-experiment at Glasgow Haskell Compiler / GHC Commits: e49a16cd by Wolfgang Jeltsch at 2026-04-11T16:46:04+03:00 Drop the construction and use of `other_fopts_map` The map was only used for a single lookup, and directly performing the lookup in the original list is faster than constructing the map and then performing the lookup in the map. - - - - - 1 changed file: - compiler/GHC/Unit/Finder.hs Changes: ===================================== compiler/GHC/Unit/Finder.hs ===================================== @@ -206,7 +206,7 @@ findImportedModuleNoHsc fc fopts ue home_module_map mhome_unit mod_name mb_pkg = case mb_pkg of NoPkgQual -> unqual_import ThisPkg uid | (homeUnitId <$> mhome_unit) == Just uid -> home_import - | Just os <- M.lookup uid other_fopts_map -> home_pkg_import (uid, os) + | Just os <- lookup uid other_fopts -> home_pkg_import (uid, os) | otherwise -> pprPanic "findImportModule" (ppr mod_name $$ ppr mb_pkg $$ ppr (homeUnitId <$> mhome_unit) $$ ppr uid $$ ppr (map fst all_opts)) OtherPkg _ -> pkg_import where @@ -214,10 +214,8 @@ findImportedModuleNoHsc fc fopts ue home_module_map mhome_unit mod_name mb_pkg = module_home_units = M.findWithDefault Set.empty mod_name module_name_map current_unit_id = homeUnitId <$> mhome_unit all_opts = case current_unit_id of - Nothing -> other_fopts_list - Just home_unit_id -> (home_unit_id, fopts) : other_fopts_list - - other_fopts_map = M.fromList other_fopts_list + Nothing -> other_fopts + Just home_unit_id -> (home_unit_id, fopts) : other_fopts home_import = case mhome_unit of 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 = -- Do not be smart and change this to `foldr orIfNotFound home_import hs` as -- that is not the same!! home_import is first because we need to look within ourselves -- first before looking at the packages in order. - any_home_import = foldr1 orIfNotFound (home_import :| map home_pkg_import other_fopts_list) + any_home_import = foldr1 orIfNotFound (home_import :| map home_pkg_import other_fopts) pkg_import = findExposedPackageModule fc fopts units mod_name mb_pkg @@ -259,7 +257,7 @@ findImportedModuleNoHsc fc fopts ue home_module_map mhome_unit mod_name mb_pkg = excluded = maybe Set.empty Set.singleton {- maybe dep_providers (\u -> Set.insert u dep_providers) -} current_unit_id in Set.toList (Set.difference candidates excluded) other_home_uids = known_other_uids ++ unknown_units - other_fopts_list = + other_fopts = [ (uid, initFinderOpts (homeUnitEnv_dflags (ue_findHomeUnitEnv uid ue))) | uid <- other_home_uids ] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e49a16cd2bc74ba3602cfae10723e3d1... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e49a16cd2bc74ba3602cfae10723e3d1... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Wolfgang Jeltsch (@jeltsch)