git.iko.soy/typeable/pandoc
on master help sign in
Avoid lazy foldl in LaTeX writer.
commitf7601297f0ff184a59efdc3ea279137fc6012eef authorJohn MacFarlane <jgm@berkeley.edu> dateMon 9 May 2016, 10:00 (10 years ago) parente08c26c
1 file changed+5−4
src/Text/Pandoc/Writers/LaTeX.hs+5−4
src/Text/Pandoc/Writers/LaTeX.hs+5−4
@@ -39,7 +39,8 @@ import Text.Pandoc.Templates
3939import Text.Printf ( printf )
4040import Network.URI ( isURI, unEscapeString )
4141import Data.Aeson (object, (.=), FromJSON)
42−import Data.List ( (\\), isInfixOf, stripPrefix, intercalate, intersperse, nub, nubBy )
42+import Data.List ( (\\), isInfixOf, stripPrefix, intercalate, intersperse,
43+ nub, nubBy, foldl' )
4344import Data.Char ( toLower, isPunctuation, isAscii, isLetter, isDigit,
4445 ord, isAlphaNum )
4546import Data.Maybe ( fromMaybe, isJust, catMaybes )
@@ -725,7 +726,7 @@ sectionHeader :: Bool -- True for unnumbered
725726 -> State WriterState Doc
726727sectionHeader unnumbered ident level lst = do
727728 txt <- inlineListToLaTeX lst
728− plain <- stringToLaTeX TextString $ foldl (++) "" $ map stringify lst
729+ plain <- stringToLaTeX TextString $ concatMap stringify lst
729730 let noNote (Note _) = Str ""
730731 noNote x = x
731732 let lstNoNotes = walk noNote lst
@@ -1037,7 +1038,7 @@ citationsToNatbib (c:cs) | citationMode c == AuthorInText = do
10371038
10381039citationsToNatbib cits = do
10391040 cits' <- mapM convertOne cits
1040− return $ text "\\citetext{" <> foldl combineTwo empty cits' <> text "}"
1041+ return $ text "\\citetext{" <> foldl' combineTwo empty cits' <> text "}"
10411042 where
10421043 combineTwo a b | isEmpty a = b
10431044 | otherwise = a <> text "; " <> b
@@ -1086,7 +1087,7 @@ citationsToBiblatex (one:[])
10861087
10871088citationsToBiblatex (c:cs) = do
10881089 args <- mapM convertOne (c:cs)
1089− return $ text cmd <> foldl (<>) empty args
1090+ return $ text cmd <> foldl' (<>) empty args
10901091 where
10911092 cmd = case citationMode c of
10921093 AuthorInText -> "\\textcites"