Skip to content

Commit 5c57564

Browse files
authored
Array.insertM: Remove write operation (#359)
…by initializing the array with the inserted element.
1 parent 7d4ca70 commit 5c57564

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

Data/HashMap/Internal/Array.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,8 @@ insert ary idx b = runST (insertM ary idx b)
303303
insertM :: Array e -> Int -> e -> ST s (Array e)
304304
insertM ary idx b =
305305
CHECK_BOUNDS("insertM", count + 1, idx)
306-
do mary <- new_ (count+1)
306+
do mary <- new (count+1) b
307307
copy ary 0 mary 0 idx
308-
write mary idx b
309308
copy ary idx mary (idx+1) (count-idx)
310309
unsafeFreeze mary
311310
where !count = length ary

0 commit comments

Comments
 (0)