on master help sign in
Shave off another 6ns for negative integers with quotRem
4869d2eBryan O'Sullivan
Data/Text/Lazy/Builder/Int.hs+4−4
@@ -73,12 +73,12 @@ decimal' :: (Integral a) => (a -> Bool) -> a -> Builder
73{-# INLINE decimal' #-}
73{-# INLINE decimal' #-}
74decimal' p i
74decimal' p i
75 | i < 0 = if p i
75 | i < 0 = if p i
76− then let j = -(i `quot` 10)
76+ then let (q, r) = (-i) `quotRem` 10
77− !n = countDigits j
77+ !n = countDigits q
78 in writeN (n + 2) $ \marr off -> do
78 in writeN (n + 2) $ \marr off -> do
79 unsafeWrite marr off minus
79 unsafeWrite marr off minus
80− posDecimal marr (off+1) n j
80+ posDecimal marr (off+1) n q
81− unsafeWrite marr (off+n+1) (i2w (-(i `rem` 10)))
81+ unsafeWrite marr (off+n+1) (i2w r)
82 else let j = -i
82 else let j = -i
83 !n = countDigits j
83 !n = countDigits j
84 in writeN (n + 1) $ \marr off ->
84 in writeN (n + 1) $ \marr off ->