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.
-- closure environment, which leads to trouble.
ASSERT (all (not . (`elemNameEnv` ce_in)) (map fst ce_additions))
extendClosureEnv ce_in ce_additions
-- 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)
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