@@ -819,17 +819,9 @@ insertNewKey !h0 !k0 x0 !m0 = go h0 k0 x0 0 m0
819
819
in Full (update32 ary i st')
820
820
where i = index h s
821
821
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))
823
823
| otherwise =
824
824
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
833
825
{-# NOINLINE insertNewKey #-}
834
826
835
827
@@ -1008,12 +1000,8 @@ insertModifyingArr :: Eq k => v -> (v -> (# v #)) -> k -> A.Array (Leaf k v)
1008
1000
insertModifyingArr x f k0 ary0 = go k0 ary0 0 (A. length ary0)
1009
1001
where
1010
1002
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
1017
1005
| otherwise = case A. index ary i of
1018
1006
(L kx y) | k == kx -> case f y of
1019
1007
(# y' # ) -> if ptrEq y y'
@@ -2164,12 +2152,8 @@ updateOrSnocWithKey :: Eq k => (k -> v -> v -> (# v #)) -> k -> v -> A.Array (Le
2164
2152
updateOrSnocWithKey f k0 v0 ary0 = go k0 v0 ary0 0 (A. length ary0)
2165
2153
where
2166
2154
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
2173
2157
| L kx y <- A. index ary i
2174
2158
, k == kx
2175
2159
, (# v2 # ) <- f k v y
0 commit comments