From 9533dcdcd9cb32800ba634659812eadb24821a79 Mon Sep 17 00:00:00 2001 From: Andrew Martin Date: Fri, 5 Jul 2019 10:54:13 -0400 Subject: [PATCH] Exploit more opportunities for reusing common decimal encoding function --- src/Data/ByteArray/Builder/Small/Unsafe.hs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/Data/ByteArray/Builder/Small/Unsafe.hs b/src/Data/ByteArray/Builder/Small/Unsafe.hs index 22bcf38..61e55e5 100644 --- a/src/Data/ByteArray/Builder/Small/Unsafe.hs +++ b/src/Data/ByteArray/Builder/Small/Unsafe.hs @@ -110,16 +110,7 @@ int64Dec (I64# w) = int64Dec# w word64Dec# :: Word# -> Builder 19 {-# noinline word64Dec# #-} word64Dec# w# = construct $ \arr off0 -> if w /= 0 - then do - 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 + then internalWordLoop arr off0 (W# w#) else do writeByteArray arr off0 (c2w '0') pure (off0 + 1)