From 142c29d90827f81bcccad35ed39f3669298b8961 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 8 Feb 2012 08:32:32 -0800 Subject: More efficient implementation of nowrap in Pretty. --- src/Text/Pandoc/Pretty.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Text/Pandoc/Pretty.hs b/src/Text/Pandoc/Pretty.hs index 8c752c1be..bf78b2594 100644 --- a/src/Text/Pandoc/Pretty.hs +++ b/src/Text/Pandoc/Pretty.hs @@ -72,7 +72,7 @@ module Text.Pandoc.Pretty ( ) where -import Data.Sequence (Seq, fromList, (<|), singleton) +import Data.Sequence (Seq, fromList, (<|), singleton, mapWithIndex) import Data.Foldable (toList) import Data.List (intercalate) import Data.Monoid @@ -408,9 +408,9 @@ beforeNonBlank d = Doc $ singleton (BeforeNonBlank d) -- | Makes a 'Doc' non-reflowable. nowrap :: Doc -> Doc -nowrap doc = Doc $ fromList $ map replaceSpace $ toList $ unDoc doc - where replaceSpace BreakingSpace = Text 1 " " - replaceSpace x = x +nowrap doc = Doc $ mapWithIndex replaceSpace $ unDoc doc + where replaceSpace _ BreakingSpace = Text 1 " " + replaceSpace _ x = x -- | Returns the width of a 'Doc'. offset :: Doc -> Int -- cgit v1.2.3