Skip to content

Commit

Permalink
alterF: Skip deleting the key when it's already absent (#288)
Browse files Browse the repository at this point in the history
Fixes #287.
  • Loading branch information
sjakobi authored Jul 21, 2020
1 parent 6f1a92f commit f508e18
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Data/HashMap/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,7 @@ alterF f = \ !k !m ->
mv = lookup' h k m
in (<$> f mv) $ \fres ->
case fres of
Nothing -> delete' h k m
Nothing -> maybe m (const (delete' h k m)) mv
Just v' -> insert' h k v' m

-- We unconditionally rewrite alterF in RULES, but we expose an
Expand Down
2 changes: 1 addition & 1 deletion Data/HashMap/Internal/Strict.hs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ alterF f = \ !k !m ->
mv = lookup' h k m
in (<$> f mv) $ \fres ->
case fres of
Nothing -> delete' h k m
Nothing -> maybe m (const (delete' h k m)) mv
Just !v' -> insert' h k v' m

-- We rewrite this function unconditionally in RULES, but we expose
Expand Down

0 comments on commit f508e18

Please sign in to comment.