Skip to content

Commit 2e7b1c4

Browse files
committed
Change position of pointer-equality check
1 parent 9a3553d commit 2e7b1c4

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

Data/HashMap/Internal.hs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,21 +1303,17 @@ alter' f h0 k0 m0 = go h0 k0 0 m0
13031303
Just v' -> bitmapIndexedOrFull (b .|. m) $! A.insert ary i $! Leaf h $! L k v'
13041304
| otherwise =
13051305
case A.index# ary i of
1306-
(# !st #) -> do
1307-
let !st' = go h k (nextShift s) st
1308-
if st' `ptrEq` st
1309-
then t
1310-
else case st' of
1311-
Empty
1312-
| A.length ary == 2
1313-
, (# l #) <- A.index# ary (otherOfOneOrZero i)
1314-
, isLeafOrCollision l
1315-
-> l
1316-
| otherwise -> bIndexed
1317-
where
1318-
bIndexed = BitmapIndexed (b .&. complement m) (A.delete ary i)
1319-
l | isLeafOrCollision l && A.length ary == 1 -> l
1320-
_ -> BitmapIndexed b (A.update ary i st')
1306+
(# !st #) -> case go h k (nextShift s) st of
1307+
Empty
1308+
| A.length ary == 2
1309+
, (# l #) <- A.index# ary (otherOfOneOrZero i)
1310+
, isLeafOrCollision l
1311+
-> l
1312+
| otherwise -> BitmapIndexed (b .&. complement m) (A.delete ary i)
1313+
st'
1314+
| isLeafOrCollision st' && A.length ary == 1 -> st'
1315+
| st' `ptrEq` st -> t
1316+
| otherwise -> BitmapIndexed b (A.update ary i st')
13211317
where
13221318
m = mask h s
13231319
i = sparseIndex b m

0 commit comments

Comments
 (0)