Skip to content

Commit

Permalink
Make IntMap split, splitLookup strict in the key
Browse files Browse the repository at this point in the history
Currently, the key is ignored for an empty map.

All IntMap and IntSet functions taking a key are strict in the key.
This allows the Int to be unboxed.
  • Loading branch information
meooow25 committed Jan 13, 2024
1 parent f5d0b13 commit b540dd2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions containers/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog for [`containers` package](http://github.com/haskell/containers)

## Next release

### Breaking changes

* `Data.IntMap.Lazy.split`, `Data.IntMap.Strict.split`,
`Data.IntMap.Lazy.splitLookup` and `Data.IntMap.Strict.splitLookup` are now
strict in the key. Previously, the key was ignored for an empty map.
(Soumik Sarkar)

## 0.7

### Breaking changes
Expand Down
4 changes: 2 additions & 2 deletions containers/src/Data/IntMap/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2815,7 +2815,7 @@ split k t =
_ -> case go k t of
(lt :*: gt) -> (lt, gt)
where
go k' t'@(Bin p m l r)
go !k' t'@(Bin p m l r)
| nomatch k' p m = if k' > p then t' :*: Nil else Nil :*: t'
| zero k' m = case go k' l of (lt :*: gt) -> lt :*: bin p m gt r
| otherwise = case go k' r of (lt :*: gt) -> bin p m l lt :*: gt
Expand Down Expand Up @@ -2857,7 +2857,7 @@ splitLookup k t =
_ -> go k t
of SplitLookup lt fnd gt -> (lt, fnd, gt)
where
go k' t'@(Bin p m l r)
go !k' t'@(Bin p m l r)
| nomatch k' p m =
if k' > p
then SplitLookup t' Nothing Nil
Expand Down

0 comments on commit b540dd2

Please sign in to comment.