diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2021-11-05 18:24:03 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-11-11 07:22:03 -0500 |
commit | c2ed85cb1e2430c089e4d00c070a2bfa2d84a4ba (patch) | |
tree | dd13f8372eabc22bb63af181cfd7d9fc3f726ca4 /compiler/GHC/Data | |
parent | 11c9a469b8857ff49aa2f0744bec001a904761e9 (diff) | |
download | haskell-c2ed85cb1e2430c089e4d00c070a2bfa2d84a4ba.tar.gz |
driver: Cache the transitive dependency calculation in ModuleGraph
Two reasons for this change:
1. Avoid computing the transitive dependencies when compiling each
module, this can save a lot of repeated work.
2. More robust to forthcoming changes to support multiple home units.
Diffstat (limited to 'compiler/GHC/Data')
-rw-r--r-- | compiler/GHC/Data/Graph/Directed.hs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/GHC/Data/Graph/Directed.hs b/compiler/GHC/Data/Graph/Directed.hs index 62482bfe30..411b22d919 100644 --- a/compiler/GHC/Data/Graph/Directed.hs +++ b/compiler/GHC/Data/Graph/Directed.hs @@ -64,6 +64,7 @@ import GHC.Types.Unique.FM import qualified Data.IntMap as IM import qualified Data.IntSet as IS import qualified Data.Map as M +import qualified Data.Set as S {- ************************************************************************ @@ -374,8 +375,8 @@ reachablesG graph froms = map (gr_vertex_to_node graph) result reachable (gr_int_graph graph) vs vs = [ v | Just v <- map (gr_node_to_vertex graph) froms ] -allReachable :: Ord key => Graph node -> (node -> key) -> M.Map key [key] -allReachable (Graph g from _) conv = M.fromList [(conv (from v), IS.foldr (\k vs -> conv (from k) : vs) [] vs) | (v, vs) <- IM.toList int_graph] +allReachable :: Ord key => Graph node -> (node -> key) -> M.Map key (S.Set key) +allReachable (Graph g from _) conv = M.fromList [(conv (from v), IS.foldr (\k vs -> conv (from k) `S.insert` vs) S.empty vs) | (v, vs) <- IM.toList int_graph] where int_graph = reachableGraph g |