diff options
author | Zubin Duggal <zubin.duggal@gmail.com> | 2021-10-10 00:02:06 +0530 |
---|---|---|
committer | Zubin Duggal <zubin.duggal@gmail.com> | 2021-10-11 12:12:59 +0530 |
commit | 76e387d196ae98ad519391a675aef8e2965f362f (patch) | |
tree | 9bf7c7c1cf5e310f0bf6f2590ba6f7fe8c7356a5 | |
parent | 31983ab4c65204ad0fd14aac4c00648f5fa6ad6b (diff) | |
download | haskell-wip/driver-topsort.tar.gz |
driver: Share the graph of dependencieswip/driver-topsort
We want to share the graph instead of recomputing it for each key.
-rw-r--r-- | compiler/GHC/Driver/Make.hs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/GHC/Driver/Make.hs b/compiler/GHC/Driver/Make.hs index 25887ee3d2..bcba8b4b96 100644 --- a/compiler/GHC/Driver/Make.hs +++ b/compiler/GHC/Driver/Make.hs @@ -1447,9 +1447,11 @@ mkNodeMap summaries = ModNodeMap $ Map.fromList -- | Efficiently construct a map from a NodeKey to its list of transitive dependencies mkDepsMap :: [ModuleGraphNode] -> (NodeKey -> [NodeKey]) -mkDepsMap nodes nk = - let (mg, lookup_node) = moduleGraphNodes False nodes - in map (mkNodeKey . node_payload) $ outgoingG mg (expectJust "mkDepsMap" (lookup_node nk)) +mkDepsMap nodes = + -- Important that we force this before returning a lambda so we can share the module graph + -- for each node + let !(mg, lookup_node) = moduleGraphNodes False nodes + in \nk -> map (mkNodeKey . node_payload) $ outgoingG mg (expectJust "mkDepsMap" (lookup_node nk)) -- | If there are {-# SOURCE #-} imports between strongly connected -- components in the topological sort, then those imports can |