Skip to content

Commit 71bfd61

Browse files
committed
Tweak Array.deleteM
1 parent 7d4ca70 commit 71bfd61

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Data/HashMap/Internal/Array.hs

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

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

0 commit comments

Comments
 (0)