Text.Pandoc.Pretty: Improve performance of realLength
Eliminates memory usage and twofold increase in speed.
commit9761283c8fd58fa04d9e04b45ef9a30325dc342e
authorMatthew Pickering <matthewtpickering@gmail.com>
dateSat 6 Dec 2014, 22:58 (12 years ago)
parentad24213
src/Text/Pandoc/Pretty.hs+1−1
@@ -534,4 +534,4 @@ charWidth c =
534534-- | Get real length of string, taking into account combining and double-wide
535535-- characters.
536536realLength :: String -> Int
537−realLength = sum . map charWidth
537+realLength = foldr (\a b -> charWidth a + b) 0