@@ -56,7 +56,7 @@ module Streamly.Internal.Data.Array.Foreign.Mut.Type
5656 , cmp
5757
5858 -- * Composable Folds
59− , toArrayMinChunk
59+ , writeWith
6060 , writeNAllocWith
6161 , writeN
6262 , writeNUnsafe
@@ -927,9 +927,9 @@ writeChunks :: (MonadIO m, Storable a) =>
927927 Int -> Fold m a (K.Stream n (Array a))
928928writeChunks n = FL.many (writeN n) FL.toStreamK
929929
930−-- XXX Compare toArrayMinChunk with fromStreamD which uses an array of streams
930+-- XXX Compare writeWith with fromStreamD which uses an array of streams
931931-- implementation. We can write this using writeChunks above if that is faster.
932−-- If toArrayMinChunk is faster then we should use that to implement
932+-- If writeWith is faster then we should use that to implement
933933-- fromStreamD.
934934--
935935-- XXX The realloc based implementation needs to make one extra copy if we use
@@ -944,11 +944,11 @@ writeChunks n = FL.many (writeN n) FL.toStreamK
944944-- XXX check if GHC's memory allocator is efficient enough. We can try the C
945945-- malloc to compare against.
946946
947−{-# INLINE_NORMAL toArrayMinChunk #-}
948−toArrayMinChunk :: forall m a. (MonadIO m, Storable a)
947+{-# INLINE_NORMAL writeWith #-}
948+writeWith :: forall m a. (MonadIO m, Storable a)
949949 => Int -> Int -> Fold m a (Array a)
950−-- toArrayMinChunk n = FL.rmapM spliceArrays $ toArraysOf n
951−toArrayMinChunk alignSize elemCount =
950+-- writeWith n = FL.rmapM spliceArrays $ toArraysOf n
951+writeWith alignSize elemCount =
952952 FL.rmapM extract $ FL.foldlM' step initial
953953
954954 where
@@ -958,7 +958,7 @@ toArrayMinChunk alignSize elemCount =
958958 return $ Array start (end `plusPtr` sizeOf (undefined :: a)) bound
959959
960960 initial = do
961− when (elemCount < 0) $ error "toArrayMinChunk: elemCount is negative"
961+ when (elemCount < 0) $ error "writeWith: elemCount is negative"
962962 liftIO $ newArrayAligned alignSize elemCount
963963 step arr@(Array start end bound) x
964964 | end `plusPtr` sizeOf (undefined :: a) > bound = do
@@ -980,7 +980,7 @@ toArrayMinChunk alignSize elemCount =
980980-- @since 0.7.0
981981{-# INLINE write #-}
982982write :: forall m a. (MonadIO m, Storable a) => Fold m a (Array a)
983−write = toArrayMinChunk (alignment (undefined :: a))
983+write = writeWith (alignment (undefined :: a))
984984 (bytesToElemCount (undefined :: a)
985985 (mkChunkSize 1024))
986986
@@ -995,7 +995,7 @@ write = toArrayMinChunk (alignment (undefined :: a))
995995writeAligned :: forall m a. (MonadIO m, Storable a)
996996 => Int -> Fold m a (Array a)
997997writeAligned alignSize =
998− toArrayMinChunk alignSize
998+ writeWith alignSize
999999 (bytesToElemCount (undefined :: a)
10001000 (mkChunkSize 1024))
10011001