on master help sign in
rename bytesToCount to make it more explicit
881d17cHarendra Kumar
src/Streamly/Memory/Array.hs+1−1
@@ -206,7 +206,7 @@ toArrayMinChunk elemCount = Fold step initial extract
206-- @since 0.7.0
206-- @since 0.7.0
207{-# INLINE write #-}
207{-# INLINE write #-}
208write :: forall m a. (MonadIO m, Storable a) => Fold m a (Array a)
208write :: 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))
210
210
211-- | Create an 'Array' from a stream. This is useful when we want to create a
211-- | Create an 'Array' from a stream. This is useful when we want to create a
212-- single array from a stream of unknown size. 'writeN' is at least twice
212-- 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
72 , shrinkToFit
72 , shrinkToFit
73 , memcpy
73 , memcpy
74 , memcmp
74 , memcmp
75− , bytesToCount
75+ , bytesToElemCount
76
76
77 , unlines
77 , unlines
78 )
78 )
@@ -213,9 +213,9 @@ memcmp p1 p2 len = do
213unsafeInlineIO :: IO a -> a
213unsafeInlineIO :: IO a -> a
214unsafeInlineIO (IO m) = case m realWorld# of (# _, r #) -> r
214unsafeInlineIO (IO m) = case m realWorld# of (# _, r #) -> r
215
215
216−{-# INLINE bytesToCount #-}
216+{-# INLINE bytesToElemCount #-}
217−bytesToCount :: Storable a => a -> Int -> Int
217+bytesToElemCount :: Storable a => a -> Int -> Int
218−bytesToCount x n =
218+bytesToElemCount x n =
219 let elemSize = sizeOf x
219 let elemSize = sizeOf x
220 in n + elemSize - 1 `div` elemSize
220 in n + elemSize - 1 `div` elemSize
221
221
src/Streamly/Memory/ArrayStream.hs+1−1
@@ -160,7 +160,7 @@ _spliceArraysBuffered s = do
160spliceArraysRealloced :: forall m a. (MonadIO m, Storable a)
160spliceArraysRealloced :: forall m a. (MonadIO m, Storable a)
161 => SerialT m (Array a) -> m (Array a)
161 => SerialT m (Array a) -> m (Array a)
162spliceArraysRealloced s = do
162spliceArraysRealloced s = do
163− idst <- liftIO $ A.newArray (A.bytesToCount (undefined :: a)
163+ idst <- liftIO $ A.newArray (A.bytesToElemCount (undefined :: a)
164 (A.mkChunkSizeKB 4))
164 (A.mkChunkSizeKB 4))
165
165
166 arr <- S.foldlM' A.spliceWithDoubling idst s
166 arr <- S.foldlM' A.spliceWithDoubling idst s