[improve performance of annexCandidates
Helmut Grohne <grohne@cs.uni-bonn.de>**20150202102739
 Ignore-this: 1c718bb7f825c270000caa850ebfdc21
 
 Profiling igor2 on the addN test shows that annexCandidates is a cost center.
 While most of the work happens in fgl, a bit of time can be saved by doing less
 work:
  * Increase lazyness by avoiding length (as used by indeg and outdeg).
  * Improve sharing by computing the Context for each node only once.
 
 This commit reduces the time spent on the test suite by 0.3%.
] hunk ./src/Igor2/Data/CallDependencies.hs 164
-annexCandidates cd  = 
-    let g  = unC . callings $ cd
-        ns = G.nodes g
-        outdegs  = map ((outdeg g) &&& id) $ ns
-        indegs  = map ((indeg g) &&& id) $ ns
-        outdeg0  = filter ((==0). fst) $ outdegs
-        outdeg1  = filter ((==1). fst) $ outdegs
-        indeg0  = filter ((==0). fst) $ indegs
-        replcbls = foldr (deleteBy ((==) `on` snd)) (outdeg0 ++ outdeg1) indeg0 
-        -- we need to remove the target functions, which are the only ones with 
+annexCandidates cd  =
+    let g        = unC $ callings cd
+        ncs      = map (G.context g &&& id) (G.nodes g)
+        outedges = map (first G.out') ncs
+        outdeg0  = [ n | (o, n) <- outedges, null o ]
+        outdeg1  = [ n | (o, n) <- outedges, case o of { [_] -> True; _ -> False } ]
+        indeg0   = [ n | (c, n) <- ncs, null (G.inn' c) ]
+        replcbls = foldr delete (outdeg0 ++ outdeg1) indeg0
+        -- we need to remove the target functions, which are the only ones with
hunk ./src/Igor2/Data/CallDependencies.hs 174
-    in mapMaybe (flip fromNode (callings cd) . snd) replcbls
-              
-allowedMaxCall :: Name                 
+    in mapMaybe (flip fromNode (callings cd)) replcbls
+
+allowedMaxCall :: Name