@@ -819,17 +819,9 @@ insertNewKey !h0 !k0 x0 !m0 = go h0 k0 x0 0 m0
819819 in Full (update32 ary i st')
820820 where i = index h s
821821 go h k x s t@ (Collision hy v)
822- | h == hy = Collision h (snocNewLeaf (L k x) v )
822+ | h == hy = Collision h (A. snoc v (L k x))
823823 | otherwise =
824824 go h k x s $ BitmapIndexed (mask hy s) (A. singleton t)
825- where
826- snocNewLeaf :: Leaf k v -> A. Array (Leaf k v ) -> A. Array (Leaf k v )
827- snocNewLeaf leaf ary = A. run $ do
828- let n = A. length ary
829- mary <- A. new_ (n + 1 )
830- A. copy ary 0 mary 0 n
831- A. write mary n leaf
832- return mary
833825{-# NOINLINE insertNewKey #-}
834826
835827
@@ -1008,12 +1000,8 @@ insertModifyingArr :: Eq k => v -> (v -> (# v #)) -> k -> A.Array (Leaf k v)
10081000insertModifyingArr x f k0 ary0 = go k0 ary0 0 (A. length ary0)
10091001 where
10101002 go ! k ! ary ! i ! n
1011- | i >= n = A. run $ do
1012- -- Not found, append to the end.
1013- mary <- A. new_ (n + 1 )
1014- A. copy ary 0 mary 0 n
1015- A. write mary n (L k x)
1016- return mary
1003+ -- Not found, append to the end.
1004+ | i >= n = A. snoc ary $ L k x
10171005 | otherwise = case A. index ary i of
10181006 (L kx y) | k == kx -> case f y of
10191007 (# y' # ) -> if ptrEq y y'
@@ -2164,12 +2152,8 @@ updateOrSnocWithKey :: Eq k => (k -> v -> v -> (# v #)) -> k -> v -> A.Array (Le
21642152updateOrSnocWithKey f k0 v0 ary0 = go k0 v0 ary0 0 (A. length ary0)
21652153 where
21662154 go ! k v ! ary ! i ! n
2167- | i >= n = A. run $ do
2168- -- Not found, append to the end.
2169- mary <- A. new_ (n + 1 )
2170- A. copy ary 0 mary 0 n
2171- A. write mary n (L k v)
2172- return mary
2155+ -- Not found, append to the end.
2156+ | i >= n = A. snoc ary $ L k v
21732157 | L kx y <- A. index ary i
21742158 , k == kx
21752159 , (# v2 # ) <- f k v y
0 commit comments