on master help sign in
Remove concatChunks, use Array.concat
commit0833f534f5ecae0cab67bfd770ba708e539825fa authorHarendra Kumar <harendra@composewell.com> dateFri 5 Jan 2024, 12:40 (3 years ago) parent901c6eb
2 files changed+4−13
core/src/Streamly/Internal/FileSystem/File.hs+2−7 core/src/Streamly/Internal/FileSystem/Handle.hs+2−6
core/src/Streamly/Internal/FileSystem/File.hs+2−7
@@ -106,12 +106,11 @@ import Streamly.Data.Fold (groupsOf, drain)
106106import Streamly.Internal.Data.Array.Type (Array(..), pinnedWriteNUnsafe)
107107import Streamly.Internal.Data.Fold.Type (Fold(..))
108108import Streamly.Data.Stream (Stream)
109−import Streamly.Internal.Data.Unbox (Unbox)
110109import Streamly.Internal.Data.Unfold.Type (Unfold(..))
111110-- import Streamly.String (encodeUtf8, decodeUtf8, foldLines)
112111import Streamly.Internal.System.IO (defaultChunkSize)
113112
114−import qualified Streamly.Data.Array as A
113+import qualified Streamly.Internal.Data.Array as A
115114import qualified Streamly.Data.Stream as S
116115import qualified Streamly.Data.Unfold as UF
117116import qualified Streamly.Internal.Data.Array.Type as IA (pinnedChunksOf)
@@ -339,10 +338,6 @@ readWithBufferOf = readerWith
339338reader :: (MonadIO m, MonadCatch m) => Unfold m FilePath Word8
340339reader = UF.many A.reader (usingFile FH.chunkReader)
341340
342−{-# INLINE concatChunks #-}
343−concatChunks :: (Monad m, Unbox a) => Stream m (Array a) -> Stream m a
344−concatChunks = S.unfoldMany A.reader
345−
346341-- | Generate a stream of bytes from a file specified by path. The stream ends
347342-- when EOF is encountered. File is locked using multiple reader and single
348343-- writer locking mode.
@@ -351,7 +346,7 @@ concatChunks = S.unfoldMany A.reader
351346--
352347{-# INLINE read #-}
353348read :: (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
355350
356351{-# DEPRECATED toBytes "Please use 'read' instead" #-}
357352{-# INLINE toBytes #-}
core/src/Streamly/Internal/FileSystem/Handle.hs+2−6
@@ -336,10 +336,6 @@ readerWith = UF.many A.reader chunkReaderWith
336336readWithBufferOf :: MonadIO m => Unfold m (Int, Handle) Word8
337337readWithBufferOf = readerWith
338338
339−{-# INLINE concatChunks #-}
340−concatChunks :: (Monad m, Unbox a) => Stream m (Array a) -> Stream m a
341−concatChunks = S.unfoldMany A.reader
342−
343339-- | @readWith bufsize handle@ reads a byte stream from a file
344340-- handle, reads are performed in chunks of up to @bufsize@.
345341--
@@ -348,7 +344,7 @@ concatChunks = S.unfoldMany A.reader
348344-- /Pre-release/
349345{-# INLINE readWith #-}
350346readWith :: MonadIO m => Int -> Handle -> Stream m Word8
351−readWith size h = concatChunks $ readChunksWith size h
347+readWith size h = A.concat $ readChunksWith size h
352348
353349-- | Unfolds a file handle into a byte stream. IO requests to the device are
354350-- performed in sizes of
@@ -367,7 +363,7 @@ reader = UF.many A.reader chunkReader
367363-- /Pre-release/
368364{-# INLINE read #-}
369365read :: MonadIO m => Handle -> Stream m Word8
370−read = concatChunks . readChunks
366+read = A.concat . readChunks
371367
372368-------------------------------------------------------------------------------
373369-- Writing