on master help sign in
Remove concatChunks, use Array.concat
0833f53Harendra Kumar
core/src/Streamly/Internal/FileSystem/File.hs+2−7
@@ -106,12 +106,11 @@ import Streamly.Data.Fold (groupsOf, drain)
106import Streamly.Internal.Data.Array.Type (Array(..), pinnedWriteNUnsafe)
106import Streamly.Internal.Data.Array.Type (Array(..), pinnedWriteNUnsafe)
107import Streamly.Internal.Data.Fold.Type (Fold(..))
107import Streamly.Internal.Data.Fold.Type (Fold(..))
108import Streamly.Data.Stream (Stream)
108import Streamly.Data.Stream (Stream)
109−import Streamly.Internal.Data.Unbox (Unbox)
110import Streamly.Internal.Data.Unfold.Type (Unfold(..))
109import Streamly.Internal.Data.Unfold.Type (Unfold(..))
111-- import Streamly.String (encodeUtf8, decodeUtf8, foldLines)
110-- import Streamly.String (encodeUtf8, decodeUtf8, foldLines)
112import Streamly.Internal.System.IO (defaultChunkSize)
111import Streamly.Internal.System.IO (defaultChunkSize)
113
112
114−import qualified Streamly.Data.Array as A
113+import qualified Streamly.Internal.Data.Array as A
115import qualified Streamly.Data.Stream as S
114import qualified Streamly.Data.Stream as S
116import qualified Streamly.Data.Unfold as UF
115import qualified Streamly.Data.Unfold as UF
117import qualified Streamly.Internal.Data.Array.Type as IA (pinnedChunksOf)
116import qualified Streamly.Internal.Data.Array.Type as IA (pinnedChunksOf)
@@ -339,10 +338,6 @@ readWithBufferOf = readerWith
339reader :: (MonadIO m, MonadCatch m) => Unfold m FilePath Word8
338reader :: (MonadIO m, MonadCatch m) => Unfold m FilePath Word8
340reader = UF.many A.reader (usingFile FH.chunkReader)
339reader = UF.many A.reader (usingFile FH.chunkReader)
341
340
342−{-# INLINE concatChunks #-}
343−concatChunks :: (Monad m, Unbox a) => Stream m (Array a) -> Stream m a
344−concatChunks = S.unfoldMany A.reader
345−
346-- | Generate a stream of bytes from a file specified by path. The stream ends
341-- | Generate a stream of bytes from a file specified by path. The stream ends
347-- when EOF is encountered. File is locked using multiple reader and single
342-- when EOF is encountered. File is locked using multiple reader and single
348-- writer locking mode.
343-- writer locking mode.
@@ -351,7 +346,7 @@ concatChunks = S.unfoldMany A.reader
351--
346--
352{-# INLINE read #-}
347{-# INLINE read #-}
353read :: (MonadIO m, MonadCatch m) => FilePath -> Stream m Word8
348read :: (MonadIO m, MonadCatch m) => FilePath -> Stream m Word8
354−read file = concatChunks $ withFile file ReadMode FH.readChunks
349+read file = A.concat $ withFile file ReadMode FH.readChunks
355
350
356{-# DEPRECATED toBytes "Please use 'read' instead" #-}
351{-# DEPRECATED toBytes "Please use 'read' instead" #-}
357{-# INLINE toBytes #-}
352{-# INLINE toBytes #-}
core/src/Streamly/Internal/FileSystem/Handle.hs+2−6
@@ -336,10 +336,6 @@ readerWith = UF.many A.reader chunkReaderWith
336readWithBufferOf :: MonadIO m => Unfold m (Int, Handle) Word8
336readWithBufferOf :: MonadIO m => Unfold m (Int, Handle) Word8
337readWithBufferOf = readerWith
337readWithBufferOf = readerWith
338
338
339−{-# INLINE concatChunks #-}
340−concatChunks :: (Monad m, Unbox a) => Stream m (Array a) -> Stream m a
341−concatChunks = S.unfoldMany A.reader
342−
343-- | @readWith bufsize handle@ reads a byte stream from a file
339-- | @readWith bufsize handle@ reads a byte stream from a file
344-- handle, reads are performed in chunks of up to @bufsize@.
340-- handle, reads are performed in chunks of up to @bufsize@.
345--
341--
@@ -348,7 +344,7 @@ concatChunks = S.unfoldMany A.reader
348-- /Pre-release/
344-- /Pre-release/
349{-# INLINE readWith #-}
345{-# INLINE readWith #-}
350readWith :: MonadIO m => Int -> Handle -> Stream m Word8
346readWith :: MonadIO m => Int -> Handle -> Stream m Word8
351−readWith size h = concatChunks $ readChunksWith size h
347+readWith size h = A.concat $ readChunksWith size h
352
348
353-- | Unfolds a file handle into a byte stream. IO requests to the device are
349-- | Unfolds a file handle into a byte stream. IO requests to the device are
354-- performed in sizes of
350-- performed in sizes of
@@ -367,7 +363,7 @@ reader = UF.many A.reader chunkReader
367-- /Pre-release/
363-- /Pre-release/
368{-# INLINE read #-}
364{-# INLINE read #-}
369read :: MonadIO m => Handle -> Stream m Word8
365read :: MonadIO m => Handle -> Stream m Word8
370−read = concatChunks . readChunks
366+read = A.concat . readChunks
371
367
372-------------------------------------------------------------------------------
368-------------------------------------------------------------------------------
373-- Writing
369-- Writing