diff options
author | John MacFarlane <jgm@berkeley.edu> | 2010-12-21 08:22:08 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2010-12-21 08:23:48 -0800 |
commit | 4e446358d1a356ba77c5f7b3cd967bf6c5285c15 (patch) | |
tree | 86d6d6010fe3cdde685d0c89e8be20a2e1ee011f | |
parent | 6aa0a187b3ec1b633fe5777967c6bf8611cbb46e (diff) | |
download | pandoc-4e446358d1a356ba77c5f7b3cd967bf6c5285c15.tar.gz |
XML: Replaced escapeStringAsXML with a faster version.
Benchmarked with criterion, it's about 8x faster than
the old version. This speeds up docbook, opendocument,
and html writers.
-rw-r--r-- | src/Text/Pandoc/XML.hs | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/src/Text/Pandoc/XML.hs b/src/Text/Pandoc/XML.hs index 0c48b48df..426521baa 100644 --- a/src/Text/Pandoc/XML.hs +++ b/src/Text/Pandoc/XML.hs @@ -55,17 +55,9 @@ escapeCharForXML x = case x of '"' -> """ c -> [c] --- | True if the character needs to be escaped. -needsEscaping :: Char -> Bool -needsEscaping c = c `elem` "&<>\"" - -- | Escape string as needed for XML. Entity references are not preserved. escapeStringForXML :: String -> String -escapeStringForXML "" = "" -escapeStringForXML str = - case break needsEscaping str of - (okay, "") -> okay - (okay, (c:cs)) -> okay ++ escapeCharForXML c ++ escapeStringForXML cs +escapeStringForXML = concatMap escapeCharForXML -- | Return a text object with a string of formatted XML attributes. attributeList :: [(String, String)] -> Doc |