Skip to content

Fix intersection #421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Data/HashMap/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1861,7 +1861,11 @@ intersectionArrayBy f !b1 !b2 !ary1 !ary2
(len, bFinal) <- go 0 0 0 bCombined bIntersect
case len of
0 -> pure Empty
1 -> A.read mary 0
1 -> do
l <- A.read mary 0
if isLeafOrCollision l
then pure l
else BitmapIndexed bFinal <$> (A.unsafeFreeze =<< A.shrink mary len)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be clearer to explicitly shrink to 1?

_ -> bitmapIndexedOrFull bFinal <$> (A.unsafeFreeze =<< A.shrink mary len)
where
bCombined = b1 .|. b2
Expand Down Expand Up @@ -1915,7 +1919,6 @@ searchSwap toFind start = go start toFind start
else go i0 k (i + 1) mary
{-# INLINE searchSwap #-}


------------------------------------------------------------------------
-- * Folds

Expand Down