Skip to content

Commit 3fb5d02

Browse files
committed
Fix
1 parent 1525e59 commit 3fb5d02

File tree

1 file changed

+7
-7
lines changed
  • core/src/Streamly/Internal/Data/MutArray

1 file changed

+7
-7
lines changed

core/src/Streamly/Internal/Data/MutArray/Generic.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ data MutArray a =
226226
, arrEnd :: {-# UNPACK #-}!Int
227227
-- ^ The length of this slice.
228228

229-
, arrCapacity :: {-# UNPACK #-}!Int
229+
, arrBound :: {-# UNPACK #-}!Int
230230
-- ^ first invalid index of arrContents.
231231
}
232232

@@ -386,7 +386,7 @@ realloc n arr = do
386386
$ IO
387387
$ \s# ->
388388
let s1# = copyMutableArray# arrC# arrS# arr1C# arr1S# newLen# s#
389-
in (# s1#, arr1 {arrEnd = newEnd, arrCapacity = n} #)
389+
in (# s1#, arr1 {arrEnd = newEnd, arrBound = n} #)
390390

391391
reallocWith ::
392392
MonadIO m => String -> (Int -> Int) -> Int -> MutArray a -> m (MutArray a)
@@ -420,9 +420,9 @@ reallocWith label sizer reqSize arr = do
420420
{-# INLINE unsafeSnoc #-}
421421
unsafeSnoc, snocUnsafe :: MonadIO m => MutArray a -> a -> m (MutArray a)
422422
unsafeSnoc arr@MutArray {..} a = do
423-
assert (arrEnd < arrCapacity) (return ())
423+
assert (arrEnd < arrBound) (return ())
424424
let arr1 = arr {arrEnd = arrEnd + 1}
425-
unsafePutIndex arrEnd arr1 a
425+
unsafePutIndex (length arr) arr1 a
426426
return arr1
427427

428428
-- NOINLINE to move it out of the way and not pollute the instruction cache.
@@ -445,7 +445,7 @@ snocWithRealloc sizer arr x = do
445445
{-# INLINE snocWith #-}
446446
snocWith :: MonadIO m => (Int -> Int) -> MutArray a -> a -> m (MutArray a)
447447
snocWith sizer arr@MutArray {..} x = do
448-
if arrEnd < arrCapacity
448+
if arrEnd < arrBound
449449
then unsafeSnoc arr x
450450
else snocWithRealloc sizer arr x
451451

@@ -476,7 +476,7 @@ snoc = snocWith (* 2)
476476
{-# INLINE uninit #-}
477477
uninit :: MonadIO m => MutArray a -> Int -> m (MutArray a)
478478
uninit arr@MutArray{..} len =
479-
if arrEnd + len <= arrCapacity
479+
if arrEnd + len <= arrBound
480480
then return $ arr {arrEnd = arrEnd + len}
481481
else realloc (length arr + len) arr
482482

@@ -784,7 +784,7 @@ chunksOf n (D.Stream step state) =
784784
putIndexUnsafeWith end contents x
785785
let end1 = end + 1
786786
return $
787-
if start + end1 >= bound
787+
if end1 >= bound
788788
then D.Skip
789789
(GroupYield
790790
contents start end1 bound (GroupStart s))

0 commit comments

Comments
 (0)