on master help sign in
Improve doc/variable naming in snocWith et al
b3cad77Harendra Kumar
src/Streamly/Internal/Data/Array/Foreign/Mut/Type.hs+7−7
@@ -455,9 +455,9 @@ reallocWith :: forall m a. (MonadIO m , Storable a) =>
455 -> Int
455 -> Int
456 -> Array a
456 -> Array a
457 -> m (Array a)
457 -> m (Array a)
458−reallocWith label allocSize reqSize arr = do
458+reallocWith label sizer reqSize arr = do
459 let oldSize = aEnd arr `minusPtr` unsafeForeignPtrToPtr (aStart arr)
459 let oldSize = aEnd arr `minusPtr` unsafeForeignPtrToPtr (aStart arr)
460− newSize = allocSize oldSize
460+ newSize = sizer oldSize
461 safeSize = max newSize (oldSize + reqSize)
461 safeSize = max newSize (oldSize + reqSize)
462 rounded = roundUpLargeArray safeSize
462 rounded = roundUpLargeArray safeSize
463 assert (newSize >= oldSize + reqSize || error badSize) (return ())
463 assert (newSize >= oldSize + reqSize || error badSize) (return ())
@@ -480,17 +480,17 @@ snocWithRealloc :: forall m a. (MonadIO m, Storable a) =>
480 -> Array a
480 -> Array a
481 -> a
481 -> a
482 -> m (Array a)
482 -> m (Array a)
483−snocWithRealloc allocSize arr x = do
483+snocWithRealloc sizer arr x = do
484 let elemSize = sizeOf (undefined :: a)
484 let elemSize = sizeOf (undefined :: a)
485− arr1 <- liftIO $ reallocWith "snocWith" allocSize elemSize arr
485+ arr1 <- liftIO $ reallocWith "snocWith" sizer elemSize arr
486 snocUnsafe arr1 x
486 snocUnsafe arr1 x
487
487
488−-- | @snocWith newSize arr elem@ mutates @arr@ to append @elem@, the length of
488+-- | @snocWith sizer arr elem@ mutates @arr@ to append @elem@. The length of
489-- the array increases by 1.
489-- the array increases by 1.
490--
490--
491-- If there is no reserved space available in @arr@ it is reallocated to a size
491-- If there is no reserved space available in @arr@ it is reallocated to a size
492−-- in bytes determined by the @newSize oldSize@ function, where @oldSize@ is
492+-- in bytes determined by the @sizer oldSizeBytes@ function, where
493−-- the original size of the array in bytes.
493+-- @oldSizeBytes@ is the original size of the array in bytes.
494--
494--
495-- If the new array size is more than 'largeObjectThreshold' we automatically
495-- If the new array size is more than 'largeObjectThreshold' we automatically
496-- round it up to 'blockSize'.
496-- round it up to 'blockSize'.