Exploit more opportunities for reusing common decimal encoding function

This commit is contained in:
Andrew Martin 2019-07-05 10:54:13 -04:00
parent 0c0b42e675
commit 9533dcdcd9

View file

@ -110,16 +110,7 @@ int64Dec (I64# w) = int64Dec# w
word64Dec# :: Word# -> Builder 19 word64Dec# :: Word# -> Builder 19
{-# noinline word64Dec# #-} {-# noinline word64Dec# #-}
word64Dec# w# = construct $ \arr off0 -> if w /= 0 word64Dec# w# = construct $ \arr off0 -> if w /= 0
then do then internalWordLoop arr off0 (W# w#)
let go off x = if x > 0
then do
let (y,z) = quotRem x 10
writeByteArray arr off (fromIntegral (z + 0x30) :: Word8)
go (off + 1) y
else do
reverseBytes arr off0 (off - 1)
pure off
go off0 w
else do else do
writeByteArray arr off0 (c2w '0') writeByteArray arr off0 (c2w '0')
pure (off0 + 1) pure (off0 + 1)