@@ -469,6 +469,11 @@ flattenArraysRev (D.Stream step state) = D.Stream step' (OuterLoop state)
469-- due to GC overhead because we need to buffer the arrays before we flatten
469-- due to GC overhead because we need to buffer the arrays before we flatten
470-- all the arrays.
470-- all the arrays.
472+-- We could take the approach of doubling the memory allocation on each
473+-- overflow. This would result in more or less the same amount of copying as in
474+-- the chunking approach. However, if we have to shrink in the end then it may
475+-- result in an extra copy of the entire data.
472{-# INLINE fromStreamD #-}
477{-# INLINE fromStreamD #-}
473fromStreamD :: (MonadIO m, Storable a) => D.Stream m a -> m (Array a)
478fromStreamD :: (MonadIO m, Storable a) => D.Stream m a -> m (Array a)
474fromStreamD m = do
479fromStreamD m = do