Skip to content

Commit e5e5d78

Browse files
committed
Rename inner go functions
1 parent 4afd2eb commit e5e5d78

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

Data/HashMap/Internal.hs

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,38 +1786,38 @@ mapKeys f = fromList . foldrWithKey (\k x xs -> (f k, x) : xs) []
17861786
-- | \(O(n \log m)\) Difference of two maps. Return elements of the first map
17871787
-- not existing in the second.
17881788
difference :: Eq k => HashMap k v -> HashMap k w -> HashMap k v
1789-
difference = go 0
1789+
difference = go_difference 0
17901790
where
1791-
go !_s Empty _ = Empty
1792-
go s t1@(Leaf h1 (L k1 _)) t2
1791+
go_difference !_s Empty _ = Empty
1792+
go_difference s t1@(Leaf h1 (L k1 _)) t2
17931793
= lookupCont (\_ -> t1) (\_ _ -> Empty) h1 k1 s t2
1794-
go _ t1 Empty = t1
1795-
go s t1 (Leaf h2 (L k2 _)) = deleteSubTree h2 k2 s t1
1794+
go_difference _ t1 Empty = t1
1795+
go_difference s t1 (Leaf h2 (L k2 _)) = deleteSubTree h2 k2 s t1
17961796

1797-
go s t1@(BitmapIndexed b1 ary1) (BitmapIndexed b2 ary2)
1797+
go_difference s t1@(BitmapIndexed b1 ary1) (BitmapIndexed b2 ary2)
17981798
= differenceArrays s b1 ary1 t1 b2 ary2
1799-
go s t1@(Full ary1) (BitmapIndexed b2 ary2)
1799+
go_difference s t1@(Full ary1) (BitmapIndexed b2 ary2)
18001800
= differenceArrays s fullBitmap ary1 t1 b2 ary2
1801-
go s t1@(BitmapIndexed b1 ary1) (Full ary2)
1801+
go_difference s t1@(BitmapIndexed b1 ary1) (Full ary2)
18021802
= differenceArrays s b1 ary1 t1 fullBitmap ary2
1803-
go s t1@(Full ary1) (Full ary2)
1803+
go_difference s t1@(Full ary1) (Full ary2)
18041804
= differenceArrays s fullBitmap ary1 t1 fullBitmap ary2
18051805

1806-
go s t1@(Collision h1 _) (BitmapIndexed b2 ary2)
1806+
go_difference s t1@(Collision h1 _) (BitmapIndexed b2 ary2)
18071807
| b2 .&. m == 0 = t1
18081808
| otherwise =
18091809
case A.index# ary2 (sparseIndex b2 m) of
1810-
(# st2 #) -> go (nextShift s) t1 st2
1810+
(# st2 #) -> go_difference (nextShift s) t1 st2
18111811
where m = mask h1 s
1812-
go s t1@(Collision h1 _) (Full ary2)
1812+
go_difference s t1@(Collision h1 _) (Full ary2)
18131813
= case A.index# ary2 (index h1 s) of
1814-
(# st2 #) -> go (nextShift s) t1 st2
1814+
(# st2 #) -> go_difference (nextShift s) t1 st2
18151815

1816-
go s t1@(BitmapIndexed b1 ary1) t2@(Collision h2 _)
1816+
go_difference s t1@(BitmapIndexed b1 ary1) t2@(Collision h2 _)
18171817
| b1 .&. m == 0 = t1
18181818
| otherwise =
18191819
let (# !st #) = A.index# ary1 i1
1820-
in case go (nextShift s) st t2 of
1820+
in case go_difference (nextShift s) st t2 of
18211821
Empty {- | A.length ary1 == 1 -> Empty -- Impossible! -}
18221822
| A.length ary1 == 2 ->
18231823
case (i1, A.index ary1 0, A.index ary1 1) of
@@ -1826,16 +1826,17 @@ difference = go 0
18261826
_ -> bIndexed
18271827
| otherwise -> bIndexed
18281828
where
1829-
bIndexed = BitmapIndexed (b1 .&. complement m) (A.delete ary1 i1)
1829+
bIndexed
1830+
= BitmapIndexed (b1 .&. complement m) (A.delete ary1 i1)
18301831
st' | isLeafOrCollision st' && A.length ary1 == 1 -> st'
18311832
| st `ptrEq` st' -> t1
18321833
| otherwise -> BitmapIndexed b1 (A.update ary1 i1 st')
18331834
where
18341835
m = mask h2 s
18351836
i1 = sparseIndex b1 m
1836-
go s t1@(Full ary1) t2@(Collision h2 _)
1837+
go_difference s t1@(Full ary1) t2@(Collision h2 _)
18371838
= let (# !st #) = A.index# ary1 i
1838-
in case go (nextShift s) st t2 of
1839+
in case go_difference (nextShift s) st t2 of
18391840
Empty ->
18401841
let ary1' = A.delete ary1 i
18411842
bm = fullBitmap .&. complement (1 `unsafeShiftL` i)
@@ -1844,7 +1845,7 @@ difference = go 0
18441845
| otherwise -> Full (updateFullArray ary1 i st')
18451846
where i = index h2 s
18461847

1847-
go _ t1@(Collision h1 ary1) (Collision h2 ary2)
1848+
go_difference _ t1@(Collision h1 ary1) (Collision h2 ary2)
18481849
= differenceCollisions h1 ary1 t1 h2 ary2
18491850

18501851
-- TODO: If we keep 'Full' (#399), differenceArrays could be optimized for
@@ -1867,7 +1868,7 @@ difference = go 0
18671868
goDA (i + 1) (i1 + 1) nextB1' (bResult .|. m) nChanges
18681869
_ -> do
18691870
!st2 <- A.indexM ary2 (sparseIndex b2 m)
1870-
case go (nextShift s) st1 st2 of
1871+
case go_difference (nextShift s) st1 st2 of
18711872
Empty -> goDA i (i1 + 1) nextB1' bResult (nChanges + 1)
18721873
st -> do
18731874
A.write mary i st

Data/HashMap/Internal/Array.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -504,21 +504,21 @@ filter f = \ ary ->
504504
let !n = length ary
505505
in run $ do
506506
mary <- new_ n
507-
len <- go ary mary 0 0 n
507+
len <- go_filter ary mary 0 0 n
508508
shrink mary len
509509
where
510510
-- Without the @!@ on @ary@ we end up reboxing the array when using
511511
-- 'differenceCollisions'. See
512512
-- https://gitlab.haskell.org/ghc/ghc/-/issues/26525.
513-
go !ary !mary !iAry !iMary !n
513+
go_filter !ary !mary !iAry !iMary !n
514514
| iAry >= n = return iMary
515515
| otherwise = do
516516
x <- indexM ary iAry
517517
if f x
518518
then do
519519
write mary iMary x
520-
go ary mary (iAry + 1) (iMary + 1) n
521-
else go ary mary (iAry + 1) iMary n
520+
go_filter ary mary (iAry + 1) (iMary + 1) n
521+
else go_filter ary mary (iAry + 1) iMary n
522522
{-# INLINE filter #-}
523523

524524
fromList :: Int -> [a] -> Array a

0 commit comments

Comments
 (0)