diff options
author | Zubin Duggal <zubin.duggal@gmail.com> | 2021-10-10 00:02:06 +0530 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-10-12 01:42:15 -0400 |
commit | 44384696bb96d30106820aeee3f7da63ed8552d9 (patch) | |
tree | 1e50b0198b0b6ad48d8276618ffd76815ba65bfb | |
parent | 8e88ef36f4915930fd33b993f81d2a4c1e7b2b2d (diff) | |
download | haskell-44384696bb96d30106820aeee3f7da63ed8552d9.tar.gz |
driver: Share the graph of dependencies
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 5f619484f2..37ca1b50f7 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 |