From 9761283c8fd58fa04d9e04b45ef9a30325dc342e Mon Sep 17 00:00:00 2001 From: Matthew Pickering Date: Sat, 6 Dec 2014 22:58:40 +0000 Subject: Text.Pandoc.Pretty: Improve performance of realLength Eliminates memory usage and twofold increase in speed. --- src/Text/Pandoc/Pretty.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Pretty.hs b/src/Text/Pandoc/Pretty.hs index 9ee7fe94a..2f2656086 100644 --- a/src/Text/Pandoc/Pretty.hs +++ b/src/Text/Pandoc/Pretty.hs @@ -534,4 +534,4 @@ charWidth c = -- | Get real length of string, taking into account combining and double-wide -- characters. realLength :: String -> Int -realLength = sum . map charWidth +realLength = foldr (\a b -> charWidth a + b) 0 -- cgit v1.2.3