@@ -126,6 +126,7 @@ module Data.HashMap.Internal
126126 , nextShift
127127 , sparseIndex
128128 , two
129+ , two'
129130 , unionArrayBy
130131 , updateFullArray
131132 , updateFullArrayM
@@ -1619,16 +1620,16 @@ unionWithKey f = go 0
16191620 | h1 == h2 = if k1 == k2
16201621 then Leaf h1 (L k1 (f k1 v1 v2))
16211622 else collision h1 l1 l2
1622- | otherwise = goDifferentHash s h1 h2 t1 t2
1623+ | otherwise = runST (two' s h1 t1 h2 t2)
16231624 go s t1@ (Leaf h1 (L k1 v1)) t2@ (Collision h2 ls2)
16241625 | h1 == h2 = Collision h1 (updateOrSnocWithKey (\ k a b -> (# f k a b # )) k1 v1 ls2)
1625- | otherwise = goDifferentHash s h1 h2 t1 t2
1626+ | otherwise = runST (two' s h1 t1 h2 t2)
16261627 go s t1@ (Collision h1 ls1) t2@ (Leaf h2 (L k2 v2))
16271628 | h1 == h2 = Collision h1 (updateOrSnocWithKey (\ k a b -> (# f k b a # )) k2 v2 ls1)
1628- | otherwise = goDifferentHash s h1 h2 t1 t2
1629+ | otherwise = runST (two' s h1 t1 h2 t2)
16291630 go s t1@ (Collision h1 ls1) t2@ (Collision h2 ls2)
16301631 | h1 == h2 = Collision h1 (updateOrConcatWithKey (\ k a b -> (# f k a b # )) ls1 ls2)
1631- | otherwise = goDifferentHash s h1 h2 t1 t2
1632+ | otherwise = runST (two' s h1 t1 h2 t2)
16321633 -- branch vs. branch
16331634 go s (BitmapIndexed b1 ary1) (BitmapIndexed b2 ary2) =
16341635 let b' = b1 .|. b2
@@ -1681,14 +1682,6 @@ unionWithKey f = go 0
16811682 leafHashCode (Leaf h _) = h
16821683 leafHashCode (Collision h _) = h
16831684 leafHashCode _ = error " leafHashCode"
1684-
1685- goDifferentHash s h1 h2 t1 t2
1686- | m1 == m2 = BitmapIndexed m1 (A. singleton $! goDifferentHash (nextShift s) h1 h2 t1 t2)
1687- | m1 < m2 = BitmapIndexed (m1 .|. m2) (A. pair t1 t2)
1688- | otherwise = BitmapIndexed (m1 .|. m2) (A. pair t2 t1)
1689- where
1690- m1 = mask h1 s
1691- m2 = mask h2 s
16921685{-# INLINE unionWithKey #-}
16931686
16941687-- | Strict in the result of @f@.
0 commit comments