Skip to content

Commit

Permalink
I can't prove we need to check validity on expiration
Browse files Browse the repository at this point in the history
Neither I nor QuickCheck can think of any reason we would have valid items.
  • Loading branch information
dustin committed Aug 21, 2023
1 parent b61dceb commit e364975
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/Data/Map/Strict/Expiring.hs
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,7 @@ expire m@Map{..} = m{ map = map', aging = aging'}
where
(todo, exact, later) = Map.splitLookup generation aging
aging' = later <> maybe mempty (Map.singleton generation) exact
map' = foldr mightDelete map (fold todo)
-- We shouldn't get here for valid generations, but we check anyway and don't delete if it's valid.
mightDelete k m = maybe (Map.delete k m) (const m) (whenValid generation =<< Map.lookup k m)

whenValid g e@(Entry a t)
| g < t = Just e
| otherwise = Nothing
map' = foldr Map.delete map (fold todo)

-- | Inspect stored size for testing.
inspect :: Ord k => Map g k a -> (Int, g, Int)
Expand Down

0 comments on commit e364975

Please sign in to comment.