Skip to content

Commit 303da19

Browse files
committed
Revert "Change position of pointer-equality check"
This reverts commit 2e7b1c4.
1 parent 64212ab commit 303da19

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

Data/HashMap/Internal.hs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,17 +1300,20 @@ alter' f !h0 !k0 = go_alter' h0 k0 0
13001300
Just v' -> bitmapIndexedOrFull (b .|. m) $! A.insert ary i $! Leaf h $! L k v'
13011301
| otherwise =
13021302
case A.index# ary i of
1303-
(# !st #) -> case go_alter' h k (nextShift s) st of
1304-
Empty
1305-
| A.length ary == 2
1306-
, (# l #) <- A.index# ary (otherOfOneOrZero i)
1307-
, isLeafOrCollision l
1308-
-> l
1309-
| otherwise -> BitmapIndexed (b .&. complement m) (A.delete ary i)
1310-
st'
1311-
| isLeafOrCollision st' && A.length ary == 1 -> st'
1312-
| st' `ptrEq` st -> t
1313-
| otherwise -> BitmapIndexed b (A.update ary i st')
1303+
(# !st #) -> do
1304+
let !st' = go_alter' h k (nextShift s) st
1305+
if st' `ptrEq` st
1306+
then t
1307+
else case st' of
1308+
Empty
1309+
| A.length ary == 2
1310+
, (# l #) <- A.index# ary (otherOfOneOrZero i)
1311+
, isLeafOrCollision l
1312+
-> l
1313+
| otherwise
1314+
-> BitmapIndexed (b .&. complement m) (A.delete ary i)
1315+
l | isLeafOrCollision l && A.length ary == 1 -> l
1316+
_ -> BitmapIndexed b (A.update ary i st')
13141317
where
13151318
m = mask h s
13161319
i = sparseIndex b m

0 commit comments

Comments
 (0)