on master help sign in
Rename "resize" to "grow"
7a0f49bHarendra Kumar
core/src/Streamly/Internal/Data/MutArray/Type.hs+23−13
@@ -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"
168− , resize
168+ , grow
169− , resizeExp
169+ , growExp
170 , rightSize
170 , rightSize
171
171
172 -- ** Folding
172 -- ** Folding
@@ -263,6 +263,8 @@ module Streamly.Internal.Data.MutArray.Type
263 , cmp
263 , cmp
264 , getIndices
264 , getIndices
265 , getIndicesWith
265 , getIndicesWith
266+ , resize
267+ , resizeExp
266 )
268 )
267where
269where
268
270
@@ -859,9 +861,7 @@ reallocWith label capSizer minIncrBytes arr = do
859 , ". Please check the sizing function passed."
861 , ". Please check the sizing function passed."
860 ]
862 ]
861
863
862−-- XXX should be called expand/extend because it never shortens the array.
863−
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.
867--
867--
@@ -869,24 +869,29 @@ reallocWith label capSizer minIncrBytes arr = do
869-- the block size (4K).
869-- the block size (4K).
870--
870--
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
881
881
882+{-# DEPRECATED resize "Please use grow instead." #-}
883+resize :: forall m a. (MonadIO m, Unbox a) =>
884+ Int -> MutArray a -> m (MutArray a)
885+resize = grow
886+
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.
884--
889--
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)
891 req1 =
896 req1 =
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
899
904
905+{-# DEPRECATED resizeExp "Please use growExp instead." #-}
906+resizeExp :: forall m a. (MonadIO m, Unbox a) =>
907+ Int -> MutArray a -> m (MutArray a)
908+resizeExp = growExp
909+
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.
902--
912--