Skip to content

Fix up alterF comments #187

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

Merged
Merged
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
13 changes: 7 additions & 6 deletions Data/HashMap/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,8 @@ data LookupRes a = Absent | Present a !Int
--
-- Outcomes:
-- Key not in map => Absent
-- Key in map, no collision => Alone v
-- Key in map, collision => Collide v position
-- Key in map, no collision => Present v (-1)
-- Key in map, collision => Present v position
lookupRecordCollision :: Eq k => Hash -> k -> HashMap k v -> LookupRes v
#if __GLASGOW_HASKELL__ >= 802
lookupRecordCollision h k m = case lookupRecordCollision# h k m of
Expand All @@ -529,9 +529,11 @@ lookupRecordCollision h k m = case lookupRecordCollision# h k m of
lookupRecordCollision# :: Eq k => Hash -> k -> HashMap k v -> (# (# #) | (# v, Int# #) #)
lookupRecordCollision# h k m =
lookupCont (\_ -> (# (# #) | #)) (\v (I# i) -> (# | (# v, i #) #)) h k m
-- INLINABLE to specialize to the Eq instance.
{-# INLINABLE lookupRecordCollision# #-}
#else
-- Pre-8.2, no unboxed sums.

#else /* GHC < 8.2 so there are no unboxed sums */

lookupRecordCollision h k m = lookupCont (\_ -> Absent) Present h k m
{-# INLINABLE lookupRecordCollision #-}
#endif
Expand Down Expand Up @@ -972,8 +974,7 @@ delete' h0 k0 m0 = go h0 k0 0 m0
| otherwise = t
{-# INLINABLE delete' #-}

-- Delete optimized for the case when we know the key is in the map and there is
-- no collision.
-- | Delete optimized for the case when we know the key is in the map.
--
-- It is only valid to call this when the key exists in the map and you know the
-- hash collision position if there was one. This information can be obtained
Expand Down