on master help sign in
Shave off another 6ns for negative integers with quotRem
commit4869d2eeb25e1b6abcae244d8cce194dbef8d5a7 authorBryan O'Sullivan <bos@serpentine.com> dateWed 20 Mar 2013, 10:08 (14 years ago) parent821f688
1 file changed+4−4
Data/Text/Lazy/Builder/Int.hs+4−4
Data/Text/Lazy/Builder/Int.hs+4−4
@@ -73,12 +73,12 @@ decimal' :: (Integral a) => (a -> Bool) -> a -> Builder
7373{-# INLINE decimal' #-}
7474decimal' p i
7575 | i < 0 = if p i
76− then let j = -(i `quot` 10)
77− !n = countDigits j
76+ then let (q, r) = (-i) `quotRem` 10
77+ !n = countDigits q
7878 in writeN (n + 2) $ \marr off -> do
7979 unsafeWrite marr off minus
80− posDecimal marr (off+1) n j
81− unsafeWrite marr (off+n+1) (i2w (-(i `rem` 10)))
80+ posDecimal marr (off+1) n q
81+ unsafeWrite marr (off+n+1) (i2w r)
8282 else let j = -i
8383 !n = countDigits j
8484 in writeN (n + 1) $ \marr off ->