@@ -295,19 +295,19 @@ removeUnnecessaryStructuralNodes (nodes, edges, mapping, association) =
295
295
regularEdges = filter isRegularEdge edges
296
296
inDegree = counter $ map (\ (from,to,_) -> from) regularEdges
297
297
outDegree = counter $ map (\ (from,to,_) -> to) regularEdges
298
- structuralNodes = S. fromList $ map fst $ filter isStructural nodes
298
+ structuralNodes = S. fromList [node | (node, CFStructuralNode ) <- nodes]
299
299
candidateNodes = S. filter isLinear structuralNodes
300
300
edgesToCollapse = S. fromList $ filter filterEdges regularEdges
301
301
302
302
remapping :: M. Map Node Node
303
- remapping = foldl' ( \ m (old, new) -> M. insert old new m) M. empty $ map orderEdge $ S. toList edgesToCollapse
304
- recursiveRemapping = M. fromList $ map (\ c -> (c, recursiveLookup remapping c)) $ M. keys remapping
303
+ remapping = M. fromList $ map orderEdge $ S. toList edgesToCollapse
304
+ recursiveRemapping = M. mapWithKey (\ c _ -> recursiveLookup remapping c) remapping
305
305
306
306
filterEdges (a,b,_) =
307
307
a `S.member` candidateNodes && b `S.member` candidateNodes
308
308
309
309
orderEdge (a,b,_) = if a < b then (b,a) else (a,b)
310
- counter = foldl' ( \ map key -> M. insertWith (+) key 1 map ) M. empty
310
+ counter = M. fromListWith (+) . map ( \ key -> ( key, 1 ))
311
311
isRegularEdge (_, _, CFEFlow ) = True
312
312
isRegularEdge _ = False
313
313
@@ -317,11 +317,6 @@ removeUnnecessaryStructuralNodes (nodes, edges, mapping, association) =
317
317
Nothing -> node
318
318
Just x -> recursiveLookup map x
319
319
320
- isStructural (node, label) =
321
- case label of
322
- CFStructuralNode -> True
323
- _ -> False
324
-
325
320
isLinear node =
326
321
M. findWithDefault 0 node inDegree == 1
327
322
&& M. findWithDefault 0 node outDegree == 1
0 commit comments