on master help sign in
rename bytesToCount to make it more explicit
commit881d17c85b83d135fb471deee03f9d603dae96bf authorHarendra Kumar <harendra.kumar@gmail.com> dateSun 11 Aug 2019, 03:36 (7 years ago) parente51d5f0
3 files changed+6−6
src/Streamly/Memory/Array.hs+1−1 src/Streamly/Memory/Array/Types.hs+4−4 src/Streamly/Memory/ArrayStream.hs+1−1
src/Streamly/Memory/Array.hs+1−1
@@ -206,7 +206,7 @@ toArrayMinChunk elemCount = Fold step initial extract
206206-- @since 0.7.0
207207{-# INLINE write #-}
208208write :: forall m a. (MonadIO m, Storable a) => Fold m a (Array a)
209−write = toArrayMinChunk (A.bytesToCount (undefined :: a) (A.mkChunkSize 1024))
209+write = toArrayMinChunk (A.bytesToElemCount (undefined :: a) (A.mkChunkSize 1024))
210210
211211-- | Create an 'Array' from a stream. This is useful when we want to create a
212212-- single array from a stream of unknown size. 'writeN' is at least twice
src/Streamly/Memory/Array/Types.hs+4−4
@@ -72,7 +72,7 @@ module Streamly.Memory.Array.Types
7272 , shrinkToFit
7373 , memcpy
7474 , memcmp
75− , bytesToCount
75+ , bytesToElemCount
7676
7777 , unlines
7878 )
@@ -213,9 +213,9 @@ memcmp p1 p2 len = do
213213unsafeInlineIO :: IO a -> a
214214unsafeInlineIO (IO m) = case m realWorld# of (# _, r #) -> r
215215
216−{-# INLINE bytesToCount #-}
217−bytesToCount :: Storable a => a -> Int -> Int
218−bytesToCount x n =
216+{-# INLINE bytesToElemCount #-}
217+bytesToElemCount :: Storable a => a -> Int -> Int
218+bytesToElemCount x n =
219219 let elemSize = sizeOf x
220220 in n + elemSize - 1 `div` elemSize
221221
src/Streamly/Memory/ArrayStream.hs+1−1
@@ -160,7 +160,7 @@ _spliceArraysBuffered s = do
160160spliceArraysRealloced :: forall m a. (MonadIO m, Storable a)
161161 => SerialT m (Array a) -> m (Array a)
162162spliceArraysRealloced s = do
163− idst <- liftIO $ A.newArray (A.bytesToCount (undefined :: a)
163+ idst <- liftIO $ A.newArray (A.bytesToElemCount (undefined :: a)
164164 (A.mkChunkSizeKB 4))
165165
166166 arr <- S.foldlM' A.spliceWithDoubling idst s