git.iko.soy/typeable/postgresql-simple
on master help sign in
Tweak pad4 implementation
commita6638dd58994a140eb8535ee16f7be0c62d840df authorLeon P Smith <leon@melding-monads.com> dateSat 2 Jun 2012, 20:31 (14 years ago) parent38bfdb4
1 file changed+5−4
src/Database/PostgreSQL/Simple/Time/Implementation.hs+5−4
src/Database/PostgreSQL/Simple/Time/Implementation.hs+5−4
@@ -272,8 +272,9 @@ pad2 n = let (a,b) = n `quotRem` 10 in p a ++ p b
272272
273273-- | pad4 assumes its input is positive
274274pad4 :: (Integral n, Show n) => n -> Builder
275−pad4 n | n >= 1000 = integral n
276− | n >= 100 = fromChar '0' ++ integral n
277− | n >= 10 = fromByteString "00" ++ integral n
278− | otherwise = fromByteString "000" ++ integral n
275+pad4 n | n >= 10000 = integral n
276+ | otherwise = p a ++ p b ++ p c ++ p d
277+ where (ab,cd) = n `quotRem` 100
278+ (a,b) = ab `quotRem` 10
279+ (c,d) = cd `quotRem` 10
279280{-# INLINE pad4 #-}