Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: c0764c69 by Hannes Siebenhandl at 2026-11-22T16:39:04-05:00 Use Set operations over Foldable operations Use `O(log n)` operations over `O(n)` for all call-sites of `hsc_all_home_unit_ids`. - - - - - 4 changed files: - compiler/GHC/Driver/Downsweep.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/Iface/Recomp.hs Changes: ===================================== compiler/GHC/Driver/Downsweep.hs ===================================== @@ -415,7 +415,7 @@ downsweepInteractiveImports hsc_env ic = unsafeInterleaveIO $ do downsweepInstalledModules :: HscEnv -> [Module] -> IO ModuleGraph downsweepInstalledModules hsc_env mods = do let - (home_mods, external_mods) = partition (\u -> moduleUnitId u `elem` hsc_all_home_unit_ids hsc_env) mods + (home_mods, external_mods) = partition (\u -> moduleUnitId u `Set.member` hsc_all_home_unit_ids hsc_env) mods installed_mods = map (fst . getModuleInstantiation) home_mods external_uids = map moduleUnitId external_mods ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -424,7 +424,7 @@ load how_much = loadWithCache noIfaceCache mkUnknownDiagnostic how_much mkBatchMsg :: HscEnv -> Messager mkBatchMsg hsc_env = - if length (hsc_all_home_unit_ids hsc_env) > 1 + if Set.size (hsc_all_home_unit_ids hsc_env) > 1 -- This also displays what unit each module is from. then batchMultiMsg else batchMsg ===================================== compiler/GHC/Iface/Load.hs ===================================== @@ -150,6 +150,7 @@ import Control.Monad import qualified Data.Foldable as Foldable import Data.Function ((&)) import Data.Map ( toList ) +import qualified Data.Set as Set import System.FilePath import System.Directory @@ -843,7 +844,7 @@ loadInterface doc_str mod from -- overlapping instances. ; massertPpr ((isOneShot (ghcMode (hsc_dflags hsc_env))) - || moduleUnitId mod `notElem` hsc_all_home_unit_ids hsc_env + || moduleUnitId mod `Set.notMember` hsc_all_home_unit_ids hsc_env || mod == gHC_PRIM) (text "Attempting to load home package interface into the EPS" $$ ppr (HUG.allUnits hug) $$ doc_str $$ ppr mod $$ ppr (moduleUnitId mod)) ; ignore_prags <- goptM Opt_IgnoreInterfacePragmas ===================================== compiler/GHC/Iface/Recomp.hs ===================================== @@ -668,7 +668,7 @@ checkDependencies hsc_env summary iface (Set.map ((SpliceLevel),) (dep_plugin_pkgs (mi_deps iface)))) classify st _ (Found _ mod) - | (toUnitId $ moduleUnit mod) `elem` all_home_units = Right (Left ((st, toUnitId $ moduleUnit mod, moduleName mod))) + | toUnitId (moduleUnit mod) `Set.member` all_home_units = Right (Left ((st, toUnitId $ moduleUnit mod, moduleName mod))) | otherwise = Right (Right (moduleNameFS (moduleName mod), (st, toUnitId $ moduleUnit mod))) classify _ reason _ = Left (RecompBecause reason) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c0764c698bbf747b1c30055bd3b7ebb6... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c0764c698bbf747b1c30055bd3b7ebb6... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help