on master help sign in
Fix a bug in "resize"
9d17f13Harendra Kumar
core/src/Streamly/Internal/Data/MutArray/Type.hs+4−6
@@ -874,9 +874,8 @@ resize :: forall m a. (MonadIO m, Unbox a) =>
874 Int -> MutArray a -> m (MutArray a)
874 Int -> MutArray a -> m (MutArray a)
875resize nElems arr@MutArray{..} = do
875resize nElems arr@MutArray{..} = do
876 let req = SIZE_OF(a) * nElems
876 let req = SIZE_OF(a) * nElems
877− -- XXX Should use arrBound
878− len = arrEnd - arrStart
877+ cap = arrBound - arrStart
879− if req < len
878+ if req < cap
880 then return arr
879 then return arr
881 else realloc req arr
880 else realloc req arr
882
881
@@ -893,9 +892,8 @@ resizeExp nElems arr@MutArray{..} = do
893 if req > largeObjectThreshold
892 if req > largeObjectThreshold
894 then roundUpToPower2 req
893 then roundUpToPower2 req
895 else req
894 else req
896− -- XXX Should use arrBound
897− len = arrEnd - arrStart
895+ cap = arrBound - arrStart
898− if req1 < len
896+ if req1 < cap
899 then return arr
897 then return arr
900 else realloc req1 arr
898 else realloc req1 arr
901
899