Fixed a bug in the datacon names extension in the dynamic linker
authorPepe Iborra <mnislaih@gmail.com>
Thu, 15 Feb 2007 18:19:34 +0000 (18:19 +0000)
committerPepe Iborra <mnislaih@gmail.com>
Thu, 15 Feb 2007 18:19:34 +0000 (18:19 +0000)
My code was doing unnecessary work when trying to get hold of all the BCOs in order to sniff the datacon names.
This involved calculating the transitive closure of a relation and was causing a huge performance slowdown in GHCi, as benchmarks uncovered. It turns out that this calculation was unnecessary.

compiler/ghci/Linker.lhs

index f59eecc..d2c7fe1 100644 (file)
@@ -750,22 +750,14 @@ linkSomeBCOs toplevs_only ie ce_in de_in ul_bcos
                     -- closure environment, which leads to trouble.
                     ASSERT (all (not . (`elemNameEnv` ce_in)) (map fst ce_additions))
                     extendClosureEnv ce_in ce_additions
-            refs  = goForRefs ul_bcos
-            names = nub$ concatMap (ssElts . unlinkedBCOItbls) (ul_bcos ++ refs)
+            names = concatMap (ssElts . unlinkedBCOItbls) ul_bcos
         addresses <- mapM (lookupIE ie) names
         let de_additions = [(address, name) | (address, name) <- zip addresses names
                                             , not(address `elemAddressEnv` de_in) 
                            ]
             de_out = extendAddressEnvList de_in de_additions
         return ( ce_out, de_out, hvals)
-    where 
-          goForRefs = getRefs []
-          getRefs acc []  = acc
-          getRefs acc new = getRefs (new++acc) 
-                 [bco | BCOPtrBCO bco <- concatMap (ssElts . unlinkedBCOPtrs) new
-                      , notElemBy bco (new ++ acc) nameEq]
-          ul1 `nameEq` ul2 = unlinkedBCOName ul1 == unlinkedBCOName ul2
-          (x1 `notElemBy` x2) eq = null$ intersectBy eq [x1] x2
+
 \end{code}