@@ -56,7 +56,7 @@ module Streamly.Internal.Data.Array.Foreign.Mut.Type
58 -- * Composable Folds
58 -- * Composable Folds
59− , toArrayMinChunk
59+ , writeWith
60 , writeNAllocWith
60 , writeNAllocWith
62 , writeNUnsafe
62 , writeNUnsafe
@@ -927,9 +927,9 @@ writeChunks :: (MonadIO m, Storable a) =>
927 Int -> Fold m a (K.Stream n (Array a))
927 Int -> Fold m a (K.Stream n (Array a))
928writeChunks n = FL.many (writeN n) FL.toStreamK
928writeChunks n = FL.many (writeN n) FL.toStreamK
930−-- XXX Compare toArrayMinChunk with fromStreamD which uses an array of streams
930+-- XXX Compare writeWith with fromStreamD which uses an array of streams
931-- implementation. We can write this using writeChunks above if that is faster.
931-- 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
933-- fromStreamD.
933-- fromStreamD.
935-- XXX The realloc based implementation needs to make one extra copy if we use
935-- 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
944-- XXX check if GHC's memory allocator is efficient enough. We can try the C
944-- XXX check if GHC's memory allocator is efficient enough. We can try the C
945-- malloc to compare against.
945-- malloc to compare against.
947−{-# INLINE_NORMAL toArrayMinChunk #-}
947+{-# INLINE_NORMAL writeWith #-}
948−toArrayMinChunk :: forall m a. (MonadIO m, Storable a)
948+writeWith :: forall m a. (MonadIO m, Storable a)
949 => Int -> Int -> Fold m a (Array a)
949 => Int -> Int -> Fold m a (Array a)
950−-- toArrayMinChunk n = FL.rmapM spliceArrays $ toArraysOf n
950+-- writeWith n = FL.rmapM spliceArrays $ toArraysOf n
951−toArrayMinChunk alignSize elemCount =
951+writeWith alignSize elemCount =
952 FL.rmapM extract $ FL.foldlM' step initial
952 FL.rmapM extract $ FL.foldlM' step initial
@@ -958,7 +958,7 @@ toArrayMinChunk alignSize elemCount =
958 return $ Array start (end `plusPtr` sizeOf (undefined :: a)) bound
958 return $ Array start (end `plusPtr` sizeOf (undefined :: a)) bound
960 initial = do
960 initial = do
961− when (elemCount < 0) $ error "toArrayMinChunk: elemCount is negative"
961+ when (elemCount < 0) $ error "writeWith: elemCount is negative"
962 liftIO $ newArrayAligned alignSize elemCount
962 liftIO $ newArrayAligned alignSize elemCount
963 step arr@(Array start end bound) x
963 step arr@(Array start end bound) x
964 | end `plusPtr` sizeOf (undefined :: a) > bound = do
964 | end `plusPtr` sizeOf (undefined :: a) > bound = do
@@ -980,7 +980,7 @@ toArrayMinChunk alignSize elemCount =
980-- @since 0.7.0
980-- @since 0.7.0
981{-# INLINE write #-}
981{-# INLINE write #-}
982write :: forall m a. (MonadIO m, Storable a) => Fold m a (Array a)
982write :: forall m a. (MonadIO m, Storable a) => Fold m a (Array a)
983−write = toArrayMinChunk (alignment (undefined :: a))
983+write = writeWith (alignment (undefined :: a))
984 (bytesToElemCount (undefined :: a)
984 (bytesToElemCount (undefined :: a)
985 (mkChunkSize 1024))
985 (mkChunkSize 1024))
@@ -995,7 +995,7 @@ write = toArrayMinChunk (alignment (undefined :: a))
995writeAligned :: forall m a. (MonadIO m, Storable a)
995writeAligned :: forall m a. (MonadIO m, Storable a)
996 => Int -> Fold m a (Array a)
996 => Int -> Fold m a (Array a)
997writeAligned alignSize =
997writeAligned alignSize =
998− toArrayMinChunk alignSize
998+ writeWith alignSize
999 (bytesToElemCount (undefined :: a)
999 (bytesToElemCount (undefined :: a)
1000 (mkChunkSize 1024))
1000 (mkChunkSize 1024))