@@ -512,8 +512,8 @@ data LookupRes a = Absent | Present a !Int
512512--
513513-- Outcomes:
514514-- Key not in map => Absent
515- -- Key in map, no collision => Alone v
516- -- Key in map, collision => Collide v position
515+ -- Key in map, no collision => Present v (-1)
516+ -- Key in map, collision => Present v position
517517lookupRecordCollision :: Eq k => Hash -> k -> HashMap k v -> LookupRes v
518518#if __GLASGOW_HASKELL__ >= 802
519519lookupRecordCollision h k m = case lookupRecordCollision# h k m of
@@ -529,9 +529,11 @@ lookupRecordCollision h k m = case lookupRecordCollision# h k m of
529529lookupRecordCollision# :: Eq k => Hash -> k -> HashMap k v -> (# (# # ) | (# v , Int # # ) # )
530530lookupRecordCollision# h k m =
531531 lookupCont (\ _ -> (# (# # ) | # )) (\ v (I # i) -> (# | (# v, i # ) # )) h k m
532+ -- INLINABLE to specialize to the Eq instance.
532533{-# INLINABLE lookupRecordCollision# #-}
533- #else
534- -- Pre-8.2, no unboxed sums.
534+
535+ #else /* GHC < 8.2 so there are no unboxed sums */
536+
535537lookupRecordCollision h k m = lookupCont (\ _ -> Absent ) Present h k m
536538{-# INLINABLE lookupRecordCollision #-}
537539#endif
@@ -972,8 +974,7 @@ delete' h0 k0 m0 = go h0 k0 0 m0
972974 | otherwise = t
973975{-# INLINABLE delete' #-}
974976
975- -- Delete optimized for the case when we know the key is in the map and there is
976- -- no collision.
977+ -- | Delete optimized for the case when we know the key is in the map.
977978--
978979-- It is only valid to call this when the key exists in the map and you know the
979980-- hash collision position if there was one. This information can be obtained
0 commit comments