Skip to content

Commit f652e27

Browse files
committed
Add bangs to tuples instead of their fields alone
This commit also adds the '$!' operator where before a tuple section was applied to a block of code wrapped in parentheses.
1 parent f55d60f commit f652e27

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

Data/HashMap/Array.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ updateWith' ary idx f = update ary idx $! f (index ary idx)
321321
-- inserting it into the array.
322322
updateWithInternal' :: Array e -> Int -> (e -> (Int, e)) -> RunResA e
323323
updateWithInternal' ary idx f =
324-
let (!sz, !e) = f (index ary idx)
324+
let !(!sz, !e) = f (index ary idx)
325325
in RunRes sz (update ary idx e)
326326
{-# INLINE updateWithInternal' #-}
327327

Data/HashMap/Base.hs

+12-12
Original file line numberDiff line numberDiff line change
@@ -529,15 +529,15 @@ insertInternal k0 v0 m0 = go h0 k0 v0 0 m0
529529
in (1, bitmapIndexedOrFull (b .|. m) ary')
530530
| otherwise =
531531
let !st = A.index ary i
532-
(!sz, !st') = go h k x (s+bitsPerSubkey) st
532+
!(!sz, !st') = go h k x (s+bitsPerSubkey) st
533533
in if st' `ptrEq` st
534534
then (sz, t)
535535
else (sz, BitmapIndexed b (A.update ary i st'))
536536
where m = mask h s
537537
i = sparseIndex b m
538538
go h k x s t@(Full ary) =
539539
let !st = A.index ary i
540-
(!sz, !st') = go h k x (s+bitsPerSubkey) st
540+
!(!sz, !st') = go h k x (s+bitsPerSubkey) st
541541
in if st' `ptrEq` st
542542
then (sz, t)
543543
else (sz, Full (update16 ary i st'))
@@ -755,8 +755,8 @@ deleteInternal k0 m0 = go h0 k0 0 m0
755755
| b .&. m == 0 = (0, t)
756756
| otherwise =
757757
let !st = A.index ary i
758-
(!sz, !st') = go h k (s+bitsPerSubkey) st
759-
in (sz,) (if st' `ptrEq` st
758+
!(!sz, !st') = go h k (s+bitsPerSubkey) st
759+
in (sz,) $! if st' `ptrEq` st
760760
then t
761761
else case st' of
762762
Empty | A.length ary == 1 -> Empty
@@ -769,28 +769,28 @@ deleteInternal k0 m0 = go h0 k0 0 m0
769769
where
770770
bIndexed = BitmapIndexed (b .&. complement m) (A.delete ary i)
771771
l | isLeafOrCollision l && A.length ary == 1 -> l
772-
_ -> BitmapIndexed b (A.update ary i st'))
772+
_ -> BitmapIndexed b (A.update ary i st')
773773
where m = mask h s
774774
i = sparseIndex b m
775775
go h k s t@(Full ary) =
776776
let !st = A.index ary i
777-
(!sz, !st') = go h k (s+bitsPerSubkey) st
778-
in (sz,) (if st' `ptrEq` st
777+
!(!sz, !st') = go h k (s+bitsPerSubkey) st
778+
in (sz,) $! if st' `ptrEq` st
779779
then t
780780
else case st' of
781781
Empty ->
782782
let ary' = A.delete ary i
783783
bm = fullNodeMask .&. complement (1 `unsafeShiftL` i)
784784
in BitmapIndexed bm ary'
785-
_ -> Full (A.update ary i st'))
785+
_ -> Full (A.update ary i st')
786786
where i = index h s
787787
go h k _ t@(Collision hy v)
788788
| h == hy = case indexOf k v of
789789
Just i
790790
| A.length v == 2 ->
791-
(-1,) (if i == 0
791+
(-1,) $!if i == 0
792792
then Leaf h (A.index v 1)
793-
else Leaf h (A.index v 0))
793+
else Leaf h (A.index v 0)
794794
| otherwise -> (-1, Collision h (A.delete v i))
795795
Nothing -> (0, t)
796796
| otherwise = (0, t)
@@ -1010,7 +1010,7 @@ unionWithKeyInternal f hm1 (HashMap siz hm2) = go 0 siz hm1 hm2
10101010
leafHashCode _ = error "leafHashCode"
10111011

10121012
goDifferentHash sz s h1 h2 t1 t2
1013-
| m1 == m2 = let (!dsz, !hm) = go sz (s+bitsPerSubkey) t1 t2
1013+
| m1 == m2 = let !(!dsz, !hm) = go sz (s+bitsPerSubkey) t1 t2
10141014
in (dsz, BitmapIndexed m1 (A.singleton hm))
10151015
| m1 < m2 = (sz, BitmapIndexed (m1 .|. m2) (A.pair t1 t2))
10161016
| otherwise = (sz, BitmapIndexed (m1 .|. m2) (A.pair t2 t1))
@@ -1066,7 +1066,7 @@ unionArrayByInternal siz f b1 b2 ary1 ary2 = A.runInternal $ do
10661066
| m > b' = return sz
10671067
| b' .&. m == 0 = go sz i i1 i2 (m `unsafeShiftL` 1)
10681068
| ba .&. m /= 0 = do
1069-
let (!dsz, !hm) = f sz (A.index ary1 i1) (A.index ary2 i2)
1069+
let !(!dsz, !hm) = f sz (A.index ary1 i1) (A.index ary2 i2)
10701070
A.write mary i hm
10711071
go dsz (i+1) (i1+1) (i2+1) (m `unsafeShiftL` 1)
10721072
| b1 .&. m /= 0 = do

Data/HashMap/Strict.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ unionWithKeyInternal f hm1 (HashMap siz hm2) = go 0 siz hm1 hm2
443443
leafHashCode _ = error "leafHashCode"
444444

445445
goDifferentHash sz s h1 h2 t1 t2
446-
| m1 == m2 = let (!dsz, !hm) = go sz (s+bitsPerSubkey) t1 t2
446+
| m1 == m2 = let !(!dsz, !hm) = go sz (s+bitsPerSubkey) t1 t2
447447
in (dsz, BitmapIndexed m1 (A.singleton hm))
448448
| m1 < m2 = (sz, BitmapIndexed (m1 .|. m2) (A.pair t1 t2))
449449
| otherwise = (sz, BitmapIndexed (m1 .|. m2) (A.pair t2 t1))

0 commit comments

Comments
 (0)