Skip to content

Commit 4afd2eb

Browse files
committed
difference*: Use A.index# instead of index
Context: #538
1 parent 5af22f6 commit 4afd2eb

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Data/HashMap/Internal.hs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,15 +1805,18 @@ difference = go 0
18051805

18061806
go s t1@(Collision h1 _) (BitmapIndexed b2 ary2)
18071807
| b2 .&. m == 0 = t1
1808-
| otherwise = go (nextShift s) t1 $! A.index ary2 (sparseIndex b2 m)
1808+
| otherwise =
1809+
case A.index# ary2 (sparseIndex b2 m) of
1810+
(# st2 #) -> go (nextShift s) t1 st2
18091811
where m = mask h1 s
18101812
go s t1@(Collision h1 _) (Full ary2)
1811-
= go (nextShift s) t1 $! A.index ary2 (index h1 s)
1813+
= case A.index# ary2 (index h1 s) of
1814+
(# st2 #) -> go (nextShift s) t1 st2
18121815

18131816
go s t1@(BitmapIndexed b1 ary1) t2@(Collision h2 _)
18141817
| b1 .&. m == 0 = t1
18151818
| otherwise =
1816-
let !st = A.index ary1 i1
1819+
let (# !st #) = A.index# ary1 i1
18171820
in case go (nextShift s) st t2 of
18181821
Empty {- | A.length ary1 == 1 -> Empty -- Impossible! -}
18191822
| A.length ary1 == 2 ->
@@ -1831,7 +1834,7 @@ difference = go 0
18311834
m = mask h2 s
18321835
i1 = sparseIndex b1 m
18331836
go s t1@(Full ary1) t2@(Collision h2 _)
1834-
= let !st = A.index ary1 i
1837+
= let (# !st #) = A.index# ary1 i
18351838
in case go (nextShift s) st t2 of
18361839
Empty ->
18371840
let ary1' = A.delete ary1 i
@@ -1899,7 +1902,8 @@ differenceCollisions !h1 !ary1 t1 !h2 !ary2
18991902
else let ary = A.filter (\(L k1 _) -> isNothing (indexOf k1 ary2)) ary1
19001903
in case A.length ary of
19011904
0 -> Empty
1902-
1 -> Leaf h1 (A.index ary 0)
1905+
1 -> case A.index# ary 0 of
1906+
(# l #) -> Leaf h1 l
19031907
n | A.length ary1 == n -> t1
19041908
| otherwise -> Collision h1 ary
19051909
| otherwise = t1

0 commit comments

Comments
 (0)