summaryrefslogtreecommitdiff
path: root/ghc
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2017-06-27 13:36:29 -0400
committerBen Gamari <ben@smart-cactus.org>2017-06-27 13:36:29 -0400
commit22b917eeb1d101cf0b6af2c94826446e4e2f2cdb (patch)
treecf842eaf2045f5ae36579b5e64200c61a8fe7b75 /ghc
parentb0708588e87554899c2efc80a2d3eba353dbe926 (diff)
downloadhaskell-22b917eeb1d101cf0b6af2c94826446e4e2f2cdb.tar.gz
Revert "Make module membership on ModuleGraph faster"
I had not intended on merging this. This reverts commit b0708588e87554899c2efc80a2d3eba353dbe926.
Diffstat (limited to 'ghc')
-rw-r--r--ghc/GHCi/UI.hs23
-rw-r--r--ghc/GHCi/UI/Tags.hs2
2 files changed, 11 insertions, 14 deletions
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs
index 6f6edd66ab..40bd0e59c3 100644
--- a/ghc/GHCi/UI.hs
+++ b/ghc/GHCi/UI.hs
@@ -1401,7 +1401,7 @@ changeDirectory "" = do
Right dir -> changeDirectory dir
changeDirectory dir = do
graph <- GHC.getModuleGraph
- when (not (null $ GHC.mgModSummaries graph)) $
+ when (not (null graph)) $
liftIO $ putStrLn "Warning: changing directory causes all loaded modules to be unloaded,\nbecause the search path has changed."
GHC.setTargets []
_ <- GHC.load LoadAllTargets
@@ -1461,8 +1461,7 @@ chooseEditFile =
do let hasFailed x = fmap not $ GHC.isLoaded $ GHC.ms_mod_name x
graph <- GHC.getModuleGraph
- failed_graph <-
- GHC.mkModuleGraph <$> filterM hasFailed (GHC.mgModSummaries graph)
+ failed_graph <- filterM hasFailed graph
let order g = flattenSCCs $ GHC.topSortModuleGraph True g Nothing
pick xs = case xs of
x : _ -> GHC.ml_hs_file (GHC.ms_location x)
@@ -1688,8 +1687,7 @@ doLoadAndCollectInfo retain_context howmuch = do
doLoad retain_context howmuch >>= \case
Succeeded | doCollectInfo -> do
- mod_summaries <- GHC.mgModSummaries <$> getModuleGraph
- loaded <- filterM GHC.isLoaded $ map GHC.ms_mod_name mod_summaries
+ loaded <- getModuleGraph >>= filterM GHC.isLoaded . map GHC.ms_mod_name
v <- mod_infos <$> getGHCiState
!newInfos <- collectInfo v loaded
modifyGHCiState (\st -> st { mod_infos = newInfos })
@@ -1734,9 +1732,8 @@ setContextAfterLoad keep_ctxt ms = do
targets <- GHC.getTargets
case [ m | Just m <- map (findTarget ms) targets ] of
[] ->
- let graph = GHC.mkModuleGraph ms
- graph' = flattenSCCs (GHC.topSortModuleGraph True graph Nothing)
- in load_this (last graph')
+ let graph' = flattenSCCs (GHC.topSortModuleGraph True ms Nothing) in
+ load_this (last graph')
(m:_) ->
load_this m
where
@@ -2814,7 +2811,7 @@ showModules = do
getLoadedModules :: GHC.GhcMonad m => m [GHC.ModSummary]
getLoadedModules = do
graph <- GHC.getModuleGraph
- filterM (GHC.isLoaded . GHC.ms_mod_name) (GHC.mgModSummaries graph)
+ filterM (GHC.isLoaded . GHC.ms_mod_name) graph
showBindings :: GHCi ()
showBindings = do
@@ -3051,7 +3048,7 @@ completeHomeModule = wrapIdentCompleter listHomeModules
listHomeModules :: String -> GHCi [String]
listHomeModules w = do
g <- GHC.getModuleGraph
- let home_mods = map GHC.ms_mod_name (GHC.mgModSummaries g)
+ let home_mods = map GHC.ms_mod_name g
dflags <- getDynFlags
return $ sort $ filter (w `isPrefixOf`)
$ map (showPpr dflags) home_mods
@@ -3493,10 +3490,10 @@ list2 _other =
listModuleLine :: Module -> Int -> InputT GHCi ()
listModuleLine modl line = do
graph <- GHC.getModuleGraph
- let this = GHC.mgLookupModule graph modl
+ let this = filter ((== modl) . GHC.ms_mod) graph
case this of
- Nothing -> panic "listModuleLine"
- Just summ -> do
+ [] -> panic "listModuleLine"
+ summ:_ -> do
let filename = expectJust "listModuleLine" (ml_hs_file (GHC.ms_location summ))
loc = mkRealSrcLoc (mkFastString (filename)) line 0
listAround (realSrcLocSpan loc) False
diff --git a/ghc/GHCi/UI/Tags.hs b/ghc/GHCi/UI/Tags.hs
index d8af7f8718..c23db57f81 100644
--- a/ghc/GHCi/UI/Tags.hs
+++ b/ghc/GHCi/UI/Tags.hs
@@ -72,7 +72,7 @@ ghciCreateTagsFile kind file = do
createTagsFile :: TagsKind -> FilePath -> GHCi ()
createTagsFile tagskind tagsFile = do
graph <- GHC.getModuleGraph
- mtags <- mapM listModuleTags (map GHC.ms_mod $ GHC.mgModSummaries graph)
+ mtags <- mapM listModuleTags (map GHC.ms_mod graph)
either_res <- liftIO $ collateAndWriteTags tagskind tagsFile $ concat mtags
case either_res of
Left e -> liftIO $ hPutStrLn stderr $ ioeGetErrorString e