Skip to content

Commit f013ce9

Browse files
committed
Tweak Array.deleteM
1 parent f59bb26 commit f013ce9

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Data/HashMap/Internal/Array.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -422,13 +422,13 @@ delete ary idx = runST (deleteM ary idx)
422422
-- | /O(n)/ Delete an element at the given position in this array,
423423
-- decreasing its size by one.
424424
deleteM :: Array e -> Int -> ST s (Array e)
425-
deleteM ary idx = do
425+
deleteM ary0 idx = do
426426
CHECK_BOUNDS("deleteM", count, idx)
427-
do mary <- new_ (count-1)
428-
copy ary 0 mary 0 idx
429-
copy ary (idx+1) mary idx (count-(idx+1))
430-
unsafeFreeze mary
431-
where !count = length ary
427+
do mary0 <- unsafeThaw ary0
428+
mary1 <- cloneM mary0 0 (count-1)
429+
copy ary0 (idx+1) mary1 idx (count-(idx+1))
430+
unsafeFreeze mary1
431+
where !count = length ary0
432432
{-# INLINE deleteM #-}
433433

434434
map :: (a -> b) -> Array a -> Array b

0 commit comments

Comments
 (0)