@@ -164,9 +164,9 @@ module Streamly.Internal.Data.MutArray.Type
164 , blockSize
164 , blockSize
165 , arrayChunkBytes
165 , arrayChunkBytes
166 , allocBytesToElemCount
166 , allocBytesToElemCount
167− , realloc
167+ , realloc -- this is "resize"
169− , resizeExp
169+ , growExp
170 , rightSize
170 , rightSize
172 -- ** Folding
172 -- ** Folding
@@ -263,6 +263,8 @@ module Streamly.Internal.Data.MutArray.Type
264 , getIndices
264 , getIndices
265 , getIndicesWith
265 , getIndicesWith
@@ -859,9 +861,7 @@ reallocWith label capSizer minIncrBytes arr = do
859 , ". Please check the sizing function passed."
861 , ". Please check the sizing function passed."
862−-- XXX should be called expand/extend because it never shortens the array.
864−-- | @resize newCapacity array@ changes the total capacity of the array so that
864+-- | @grow newCapacity array@ changes the total capacity of the array so that
865-- it is enough to hold the specified number of elements. Nothing is done if
865-- it is enough to hold the specified number of elements. Nothing is done if
866-- the specified capacity is less than the length of the array.
866-- the specified capacity is less than the length of the array.
@@ -869,24 +869,29 @@ reallocWith label capSizer minIncrBytes arr = do
869-- the block size (4K).
869-- the block size (4K).
871-- /Pre-release/
871-- /Pre-release/
872−{-# INLINE resize #-}
872+{-# INLINE grow #-}
873−resize :: forall m a. (MonadIO m, Unbox a) =>
873+grow :: forall m a. (MonadIO m, Unbox a) =>
874 Int -> MutArray a -> m (MutArray a)
874 Int -> MutArray a -> m (MutArray a)
875−resize nElems arr@MutArray{..} = do
875+grow nElems arr@MutArray{..} = do
876 let req = SIZE_OF(a) * nElems
876 let req = SIZE_OF(a) * nElems
877 cap = arrBound - arrStart
877 cap = arrBound - arrStart
878 if req < cap
878 if req < cap
879 then return arr
879 then return arr
880 else realloc req arr
880 else realloc req arr
882+{-# DEPRECATED resize "Please use grow instead." #-}
883+resize :: forall m a. (MonadIO m, Unbox a) =>
884+ Int -> MutArray a -> m (MutArray a)
882−-- | Like 'resize' but if the requested byte capacity is more than
887+-- | Like 'grow' but if the requested byte capacity is more than
883-- 'largeObjectThreshold' then it is rounded up to the closest power of 2.
888-- 'largeObjectThreshold' then it is rounded up to the closest power of 2.
885-- /Pre-release/
890-- /Pre-release/
886−{-# INLINE resizeExp #-}
891+{-# INLINE growExp #-}
887−resizeExp :: forall m a. (MonadIO m, Unbox a) =>
892+growExp :: forall m a. (MonadIO m, Unbox a) =>
888 Int -> MutArray a -> m (MutArray a)
893 Int -> MutArray a -> m (MutArray a)
889−resizeExp nElems arr@MutArray{..} = do
894+growExp nElems arr@MutArray{..} = do
890 let req = roundUpLargeArray (SIZE_OF(a) * nElems)
895 let req = roundUpLargeArray (SIZE_OF(a) * nElems)
892 if req > largeObjectThreshold
897 if req > largeObjectThreshold
@@ -897,6 +902,11 @@ resizeExp nElems arr@MutArray{..} = do
897 then return arr
902 then return arr
898 else realloc req1 arr
903 else realloc req1 arr
905+{-# DEPRECATED resizeExp "Please use growExp instead." #-}
906+resizeExp :: forall m a. (MonadIO m, Unbox a) =>
907+ Int -> MutArray a -> m (MutArray a)
900-- | Resize the allocated memory to drop any reserved free space at the end of
910-- | Resize the allocated memory to drop any reserved free space at the end of
901-- the array and reallocate it to reduce wastage.
911-- the array and reallocate it to reduce wastage.