File tree 2 files changed +13
-1
lines changed
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 53
53
54
54
* Add ` foldMap ` for ` Data.IntSet ` . (Soumik Sarkar)
55
55
56
+ ### Performance improvements
57
+
58
+ * For ` Data.Graph.SCC ` , ` Foldable.toList ` and ` Foldable1.toNonEmpty ` now
59
+ do not perform a copy. (Soumik Sarkar)
60
+
56
61
## Unreleased with ` @since ` annotation for 0.7.1:
57
62
58
63
### Additions
Original file line number Diff line number Diff line change @@ -220,11 +220,16 @@ instance F.Foldable SCC where
220
220
foldr c n (AcyclicSCC v) = c v n
221
221
foldr c n (NECyclicSCC vs) = foldr c n vs
222
222
223
+ toList = flattenSCC
224
+
223
225
#if MIN_VERSION_base(4,18,0)
224
226
-- | @since 0.7.0
225
227
instance F1. Foldable1 SCC where
226
228
foldMap1 f (AcyclicSCC v) = f v
227
229
foldMap1 f (NECyclicSCC vs) = F1. foldMap1 f vs
230
+
231
+ toNonEmpty = flattenSCC1
232
+
228
233
-- TODO define more methods
229
234
#endif
230
235
@@ -258,7 +263,9 @@ flattenSCCs = concatMap flattenSCC
258
263
-- This function is retained for backward compatibility,
259
264
-- 'flattenSCC1' has the more precise type.
260
265
flattenSCC :: SCC vertex -> [vertex ]
261
- flattenSCC = NE. toList . flattenSCC1
266
+ flattenSCC (AcyclicSCC v) = [v]
267
+ flattenSCC (NECyclicSCC (v :| vs)) = v : vs
268
+ -- Note: Best to avoid NE.toList, it is too lazy.
262
269
263
270
-- | The vertices of a strongly connected component.
264
271
--
You can’t perform that action at this time.
0 commit comments