@@ -116,9 +116,9 @@ module Data.HashMap.Internal
116
116
, sparseIndex
117
117
, two
118
118
, unionArrayBy
119
- , update16
120
- , update16M
121
- , update16With '
119
+ , update32
120
+ , update32M
121
+ , update32With '
122
122
, updateOrConcatWith
123
123
, updateOrConcatWithKey
124
124
, filterMapAux
@@ -809,7 +809,7 @@ insert' h0 k0 v0 m0 = go h0 k0 v0 0 m0
809
809
! st' = go h k x (s+ bitsPerSubkey) st
810
810
in if st' `ptrEq` st
811
811
then t
812
- else Full (update16 ary i st')
812
+ else Full (update32 ary i st')
813
813
where i = index h s
814
814
go h k x s t@ (Collision hy v)
815
815
| h == hy = Collision h (updateOrSnocWith (\ a _ -> (# a # )) k x v)
@@ -843,7 +843,7 @@ insertNewKey !h0 !k0 x0 !m0 = go h0 k0 x0 0 m0
843
843
go h k x s (Full ary) =
844
844
let ! st = A. index ary i
845
845
! st' = go h k x (s+ bitsPerSubkey) st
846
- in Full (update16 ary i st')
846
+ in Full (update32 ary i st')
847
847
where i = index h s
848
848
go h k x s t@ (Collision hy v)
849
849
| h == hy = Collision h (snocNewLeaf (L k x) v)
@@ -887,7 +887,7 @@ insertKeyExists !collPos0 !h0 !k0 x0 !m0 = go collPos0 h0 k0 x0 0 m0
887
887
go collPos h k x s (Full ary) =
888
888
let ! st = A. index ary i
889
889
! st' = go collPos h k x (s+ bitsPerSubkey) st
890
- in Full (update16 ary i st')
890
+ in Full (update32 ary i st')
891
891
where i = index h s
892
892
go collPos h k x _s (Collision _hy v)
893
893
| collPos >= 0 = Collision h (setAtPosition collPos k x v)
@@ -1015,7 +1015,7 @@ insertModifying x f k0 m0 = go h0 k0 0 m0
1015
1015
go h k s t@ (Full ary) =
1016
1016
let ! st = A. index ary i
1017
1017
! st' = go h k (s+ bitsPerSubkey) st
1018
- ary' = update16 ary i $! st'
1018
+ ary' = update32 ary i $! st'
1019
1019
in if ptrEq st st'
1020
1020
then t
1021
1021
else Full ary'
@@ -1236,7 +1236,7 @@ adjust# f k0 m0 = go h0 k0 0 m0
1236
1236
let i = index h s
1237
1237
! st = A. index ary i
1238
1238
! st' = go h k (s+ bitsPerSubkey) st
1239
- ary' = update16 ary i $! st'
1239
+ ary' = update32 ary i $! st'
1240
1240
in if ptrEq st st'
1241
1241
then t
1242
1242
else Full ary'
@@ -1622,12 +1622,12 @@ unionWithKey f = go 0
1622
1622
go s (Full ary1) t2 =
1623
1623
let h2 = leafHashCode t2
1624
1624
i = index h2 s
1625
- ary' = update16With ' ary1 i $ \ st1 -> go (s+ bitsPerSubkey) st1 t2
1625
+ ary' = update32With ' ary1 i $ \ st1 -> go (s+ bitsPerSubkey) st1 t2
1626
1626
in Full ary'
1627
1627
go s t1 (Full ary2) =
1628
1628
let h1 = leafHashCode t1
1629
1629
i = index h1 s
1630
- ary' = update16With ' ary2 i $ \ st2 -> go (s+ bitsPerSubkey) t1 st2
1630
+ ary' = update32With ' ary2 i $ \ st2 -> go (s+ bitsPerSubkey) t1 st2
1631
1631
in Full ary'
1632
1632
1633
1633
leafHashCode (Leaf h _) = h
@@ -2252,36 +2252,36 @@ subsetArray cmpV ary1 ary2 = A.length ary1 <= A.length ary2 && A.all inAry2 ary1
2252
2252
-- Manually unrolled loops
2253
2253
2254
2254
-- | /O(n)/ Update the element at the given position in this array.
2255
- update16 :: A. Array e -> Int -> e -> A. Array e
2256
- update16 ary idx b = runST (update16M ary idx b)
2257
- {-# INLINE update16 #-}
2255
+ update32 :: A. Array e -> Int -> e -> A. Array e
2256
+ update32 ary idx b = runST (update32M ary idx b)
2257
+ {-# INLINE update32 #-}
2258
2258
2259
2259
-- | /O(n)/ Update the element at the given position in this array.
2260
- update16M :: A. Array e -> Int -> e -> ST s (A. Array e )
2261
- update16M ary idx b = do
2262
- mary <- clone16 ary
2260
+ update32M :: A. Array e -> Int -> e -> ST s (A. Array e )
2261
+ update32M ary idx b = do
2262
+ mary <- clone ary
2263
2263
A. write mary idx b
2264
2264
A. unsafeFreeze mary
2265
- {-# INLINE update16M #-}
2265
+ {-# INLINE update32M #-}
2266
2266
2267
2267
-- | /O(n)/ Update the element at the given position in this array, by applying a function to it.
2268
- update16With ' :: A. Array e -> Int -> (e -> e ) -> A. Array e
2269
- update16With ' ary idx f
2268
+ update32With ' :: A. Array e -> Int -> (e -> e ) -> A. Array e
2269
+ update32With ' ary idx f
2270
2270
| (# x # ) <- A. index# ary idx
2271
- = update16 ary idx $! f x
2272
- {-# INLINE update16With ' #-}
2271
+ = update32 ary idx $! f x
2272
+ {-# INLINE update32With ' #-}
2273
2273
2274
- -- | Unsafely clone an array of 16 elements. The length of the input
2274
+ -- | Unsafely clone an array of (2^bitsPerSubkey) elements. The length of the input
2275
2275
-- array is not checked.
2276
- clone16 :: A. Array e -> ST s (A. MArray s e )
2277
- clone16 ary =
2278
- A. thaw ary 0 16
2276
+ clone :: A. Array e -> ST s (A. MArray s e )
2277
+ clone ary =
2278
+ A. thaw ary 0 ( 2 ^ bitsPerSubkey)
2279
2279
2280
2280
------------------------------------------------------------------------
2281
2281
-- Bit twiddling
2282
2282
2283
2283
bitsPerSubkey :: Int
2284
- bitsPerSubkey = 4
2284
+ bitsPerSubkey = 5
2285
2285
2286
2286
maxChildren :: Int
2287
2287
maxChildren = 1 `unsafeShiftL` bitsPerSubkey
@@ -2291,6 +2291,7 @@ subkeyMask = 1 `unsafeShiftL` bitsPerSubkey - 1
2291
2291
2292
2292
sparseIndex :: Bitmap -> Bitmap -> Int
2293
2293
sparseIndex b m = popCount (b .&. (m - 1 ))
2294
+ {-# INLINE sparseIndex #-}
2294
2295
2295
2296
mask :: Word -> Shift -> Bitmap
2296
2297
mask w s = 1 `unsafeShiftL` index w s
0 commit comments