Skip to content

Commit

Permalink
Make two strict in its key arguments
Browse files Browse the repository at this point in the history
`two` wasn't strict in its key arguments. We thought this was okay,
because its key arguments are always in WHNF and it's marked
`INLINE`. But `two` is defined as a *recursive* `go` function
(I haven't looked into why), which can't be inlined. I believe
that's the reason GHC doesn't *realize* that the keys are in WHNF.
Anyway, the end result was that `two` would defer the creation of
the `Leaf` values stored in the array, producing very silly thunks.

Fixes haskell-unordered-containers#232
  • Loading branch information
treeowl committed May 6, 2019
1 parent 601b5ae commit 5cbf8c5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Data/HashMap/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -831,10 +831,10 @@ two = go
| bp1 == bp2 = do
st <- go (s+bitsPerSubkey) h1 k1 v1 h2 k2 v2
ary <- A.singletonM st
return $! BitmapIndexed bp1 ary
return $ BitmapIndexed bp1 ary
| otherwise = do
mary <- A.new 2 $ Leaf h1 (L k1 v1)
A.write mary idx2 $ Leaf h2 (L k2 v2)
mary <- A.new 2 $! Leaf h1 (L k1 v1)
A.write mary idx2 $! Leaf h2 (L k2 v2)
ary <- A.unsafeFreeze mary
return $! BitmapIndexed (bp1 .|. bp2) ary
where
Expand Down

0 comments on commit 5cbf8c5

Please sign in to comment.