From 44384696bb96d30106820aeee3f7da63ed8552d9 Mon Sep 17 00:00:00 2001 From: Zubin Duggal Date: Sun, 10 Oct 2021 00:02:06 +0530 Subject: driver: Share the graph of dependencies We want to share the graph instead of recomputing it for each key. --- compiler/GHC/Driver/Make.hs | 8 +++++--- 1 file 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 -- cgit v1.2.1