on master help sign in
Replace uses of quot and rem with quotRem

Astonishingly (at least to me), this improves performance by almost 30% for large integers.

commit821f68850e30504d42c61f1e56319fc95eca6375 authorBryan O'Sullivan <bos@serpentine.com> dateWed 20 Mar 2013, 10:01 (14 years ago) parent8d0f235
1 file changed+3−3
Data/Text/Lazy/Builder/Int.hs+3−3
Data/Text/Lazy/Builder/Int.hs+3−3
@@ -107,9 +107,9 @@ posDecimal :: (Integral a) =>
107107posDecimal marr off0 ds v0 = go (off0 + ds - 1) v0
108108 where go off v
109109 | v >= 100 = do
110− write2 off $ let u = v `rem` 100
111− in u + u
112− go (off - 2) (v `quot` 100)
110+ let (q, r) = v `quotRem` 100
111+ write2 off (r + r)
112+ go (off - 2) q
113113 | v < 10 = unsafeWrite marr off (i2w v)
114114 | otherwise = write2 off (v + v)
115115 write2 off i = do