Text.Pandoc.Pretty: Improve performance of realLength

Eliminates memory usage and twofold increase in speed.
This commit is contained in:
Matthew Pickering 2014-12-06 22:58:40 +00:00
parent ad242131b9
commit 9761283c8f

View file

@ -534,4 +534,4 @@ charWidth c =
-- | Get real length of string, taking into account combining and double-wide -- | Get real length of string, taking into account combining and double-wide
-- characters. -- characters.
realLength :: String -> Int realLength :: String -> Int
realLength = sum . map charWidth realLength = foldr (\a b -> charWidth a + b) 0