Skip to content

Commit

Permalink
Handle non-exhaustive patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
la-wu committed Feb 25, 2021
1 parent 08dd00a commit 70f715d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions Data/ByteString/Builder/RealFloat/D2S.hs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ unifySmallTrailing :: FloatingDecimal -> FloatingDecimal
unifySmallTrailing fd@(FloatingDecimal (W64# m) e) =
let !(# q, r #) = dquotRem10 m
in case r `neWord#` 0## of
1# -> fd
0# -> unifySmallTrailing $ FloatingDecimal (W64# q) (e + 1)
_ -> fd

-- TODO: 128-bit intrinsics
mulShift64Unboxed :: Word# -> (# Word#, Word# #) -> Int# -> Word#
Expand Down Expand Up @@ -172,9 +172,9 @@ trimTrailing d =
trimNoTrailing'' :: Word# -> Word# -> Word# -> Word# -> Int# -> (# Word#, Word#, Word#, Int# #)
trimNoTrailing'' u' v' w' lastRemoved count =
case vw' `gtWord#` vu' of
1# -> let !(# vv', ld #) = dquotRem10 v'
in trimNoTrailing' vu' vv' vw' ld (count +# 1#)
0# -> (# u', v', lastRemoved , count #)
_ -> let !(# vv', ld #) = dquotRem10 v'
in trimNoTrailing' vu' vv' vw' ld (count +# 1#)
where
!vu' = dquot10 u'
!vw' = dquot10 w'
Expand All @@ -188,10 +188,10 @@ trimNoTrailing' u' v' w' lastRemoved count =
let !vw' = dquot100 w'
!vu' = dquot100 u'
in case vw' `gtWord#` vu' of
1# -> let !vv' = dquot100 v'
0# -> trimNoTrailing'' u' v' w' lastRemoved count
_ -> let !vv' = dquot100 v'
!ld = dquot10 (v' `minusWord#` (vv' `timesWord#` 100##))
in trimNoTrailing'' vu' vv' vw' ld (count +# 2#)
0# -> trimNoTrailing'' u' v' w' lastRemoved count

trimNoTrailing :: BoundsState -> (BoundsState, Int32)
trimNoTrailing !(BoundsState (W64# u' ) (W64# v') (W64# w') (W64# ld) _ _) =
Expand Down
12 changes: 6 additions & 6 deletions Data/ByteString/Builder/RealFloat/F2S.hs
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ trimTrailing !d =
trimNoTrailing' :: Word# -> Word# -> Word# -> Word# -> Int# -> (# Word#, Word#, Word#, Int# #)
trimNoTrailing' u' v' w' lastRemoved count =
case vw' `gtWord#` vu' of
1# -> let !(# vv', ld #) = fquotRem10 v'
in trimNoTrailing' vu' vv' vw' ld (count +# 1#)
0# -> (# u', v', lastRemoved , count #)
_ -> let !(# vv', ld #) = fquotRem10 v'
in trimNoTrailing' vu' vv' vw' ld (count +# 1#)
where
!vu' = fquot10 u'
!vw' = fquot10 w'
Expand All @@ -164,9 +164,9 @@ f2dGT (I32# e2) (W32# u) (W32# v) (W32# w) =
-- below. We could use q = X - 1 above, except that would require 33
-- bits for the result, and we've found that 32-bit arithmetic is
-- faster even on 64-bit machines.
1# -> let l = unbox float_pow5_inv_bitcount +# pow5bitsUnboxed (word2Int# q -# 1#) -# 1#
in frem10 (mulPow5InvDivPow2 v (q `minusWord#` 1##) (negateInt# e2 +# word2Int# q -# 1# +# l))
0# -> 0##
_ -> let l = unbox float_pow5_inv_bitcount +# pow5bitsUnboxed (word2Int# q -# 1#) -# 1#
in frem10 (mulPow5InvDivPow2 v (q `minusWord#` 1##) (negateInt# e2 +# word2Int# q -# 1# +# l))
!(# vvTrailing, vuTrailing, vw' #) =
case () of
_ | isTrue# ((q `leWord#` 9##) `andI#` (frem5 v `eqWord#` 0##))
Expand All @@ -191,9 +191,9 @@ f2dLT (I32# e2) (W32# u) (W32# v) (W32# w) =
w' = mulPow5DivPow2 w i j
!lastRemoved =
case (q `neWord#` 0##) `andI#` ((fquot10 (u'`minusWord#` 1##)) `leWord#` fquot10 u') of
1# -> let j' = word2Int# q -# 1# -# (pow5bitsUnboxed (i +# 1#) -# unbox float_pow5_bitcount)
in frem10 (mulPow5DivPow2 v (i +# 1#) j')
0# -> 0##
_ -> let j' = word2Int# q -# 1# -# (pow5bitsUnboxed (i +# 1#) -# unbox float_pow5_bitcount)
in frem10 (mulPow5DivPow2 v (i +# 1#) j')
!(# vvTrailing , vuTrailing, vw' #) =
case () of
_ | isTrue# ((q `leWord#` 1##) `andI#` acceptBoundsUnboxed v)
Expand Down
2 changes: 1 addition & 1 deletion Data/ByteString/Builder/RealFloat/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ pow5_factor w count =
let !(# q, r #) = dquotRem5 w
in case r `eqWord#` 0## of
0# -> count
1# -> pow5_factor q (count +# 1#)
_ -> pow5_factor q (count +# 1#)

multipleOfPowerOf5_Unboxed :: Word# -> Word# -> Int#
multipleOfPowerOf5_Unboxed value p = pow5_factor value 0# >=# word2Int# p
Expand Down

0 comments on commit 70f715d

Please sign in to comment.