Skip to content

Commit ec84ad5

Browse files
committed
Make two strict in its key arguments
`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 #232
1 parent 601b5ae commit ec84ad5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Data/HashMap/Base.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -831,10 +831,10 @@ two = go
831831
| bp1 == bp2 = do
832832
st <- go (s+bitsPerSubkey) h1 k1 v1 h2 k2 v2
833833
ary <- A.singletonM st
834-
return $! BitmapIndexed bp1 ary
834+
return $ BitmapIndexed bp1 ary
835835
| otherwise = do
836-
mary <- A.new 2 $ Leaf h1 (L k1 v1)
837-
A.write mary idx2 $ Leaf h2 (L k2 v2)
836+
mary <- A.new 2 $! Leaf h1 (L k1 v1)
837+
A.write mary idx2 $! Leaf h2 (L k2 v2)
838838
ary <- A.unsafeFreeze mary
839839
return $! BitmapIndexed (bp1 .|. bp2) ary
840840
where

0 commit comments

Comments
 (0)