@@ -116,9 +116,9 @@ module Data.HashMap.Internal
116116 , sparseIndex
117117 , two
118118 , unionArrayBy
119- , update16
120- , update16M
121- , update16With '
119+ , update32
120+ , update32M
121+ , update32With '
122122 , updateOrConcatWith
123123 , updateOrConcatWithKey
124124 , filterMapAux
@@ -809,7 +809,7 @@ insert' h0 k0 v0 m0 = go h0 k0 v0 0 m0
809809 ! st' = go h k x (s+ bitsPerSubkey) st
810810 in if st' `ptrEq` st
811811 then t
812- else Full (update16 ary i st')
812+ else Full (update32 ary i st')
813813 where i = index h s
814814 go h k x s t@ (Collision hy v)
815815 | 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
843843 go h k x s (Full ary) =
844844 let ! st = A. index ary i
845845 ! st' = go h k x (s+ bitsPerSubkey) st
846- in Full (update16 ary i st')
846+ in Full (update32 ary i st')
847847 where i = index h s
848848 go h k x s t@ (Collision hy v)
849849 | 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
887887 go collPos h k x s (Full ary) =
888888 let ! st = A. index ary i
889889 ! st' = go collPos h k x (s+ bitsPerSubkey) st
890- in Full (update16 ary i st')
890+ in Full (update32 ary i st')
891891 where i = index h s
892892 go collPos h k x _s (Collision _hy v)
893893 | collPos >= 0 = Collision h (setAtPosition collPos k x v)
@@ -1015,7 +1015,7 @@ insertModifying x f k0 m0 = go h0 k0 0 m0
10151015 go h k s t@ (Full ary) =
10161016 let ! st = A. index ary i
10171017 ! st' = go h k (s+ bitsPerSubkey) st
1018- ary' = update16 ary i $! st'
1018+ ary' = update32 ary i $! st'
10191019 in if ptrEq st st'
10201020 then t
10211021 else Full ary'
@@ -1236,7 +1236,7 @@ adjust# f k0 m0 = go h0 k0 0 m0
12361236 let i = index h s
12371237 ! st = A. index ary i
12381238 ! st' = go h k (s+ bitsPerSubkey) st
1239- ary' = update16 ary i $! st'
1239+ ary' = update32 ary i $! st'
12401240 in if ptrEq st st'
12411241 then t
12421242 else Full ary'
@@ -1622,12 +1622,12 @@ unionWithKey f = go 0
16221622 go s (Full ary1) t2 =
16231623 let h2 = leafHashCode t2
16241624 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
16261626 in Full ary'
16271627 go s t1 (Full ary2) =
16281628 let h1 = leafHashCode t1
16291629 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
16311631 in Full ary'
16321632
16331633 leafHashCode (Leaf h _) = h
@@ -2252,36 +2252,36 @@ subsetArray cmpV ary1 ary2 = A.length ary1 <= A.length ary2 && A.all inAry2 ary1
22522252-- Manually unrolled loops
22532253
22542254-- | /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 #-}
22582258
22592259-- | /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
22632263 A. write mary idx b
22642264 A. unsafeFreeze mary
2265- {-# INLINE update16M #-}
2265+ {-# INLINE update32M #-}
22662266
22672267-- | /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
22702270 | (# x # ) <- A. index# ary idx
2271- = update16 ary idx $! f x
2272- {-# INLINE update16With ' #-}
2271+ = update32 ary idx $! f x
2272+ {-# INLINE update32With ' #-}
22732273
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
22752275-- 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)
22792279
22802280------------------------------------------------------------------------
22812281-- Bit twiddling
22822282
22832283bitsPerSubkey :: Int
2284- bitsPerSubkey = 4
2284+ bitsPerSubkey = 5
22852285
22862286maxChildren :: Int
22872287maxChildren = 1 `unsafeShiftL` bitsPerSubkey
@@ -2291,6 +2291,7 @@ subkeyMask = 1 `unsafeShiftL` bitsPerSubkey - 1
22912291
22922292sparseIndex :: Bitmap -> Bitmap -> Int
22932293sparseIndex b m = popCount (b .&. (m - 1 ))
2294+ {-# INLINE sparseIndex #-}
22942295
22952296mask :: Word -> Shift -> Bitmap
22962297mask w s = 1 `unsafeShiftL` index w s
0 commit comments