aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-03-11 18:42:39 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2017-03-11 18:42:39 +0100
commitbe733385c9457a006da2b5d92fed0077401c3d1c (patch)
tree27e04c79a03184678aeaf32327bce30337b1494a /src/Text
parentac15b0443f942771003508ccbe891954242fd07f (diff)
downloadpandoc-be733385c9457a006da2b5d92fed0077401c3d1c.tar.gz
Markdown reader: optimized nonindentSpaces.
Makes the benchmark go from 40 to 36 ms.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index 2cd1c0d83..169872391 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -133,17 +133,14 @@ indentSpaces = try $ do
nonindentSpaces :: PandocMonad m => MarkdownParser m String
nonindentSpaces = do
- tabStop <- getOption readerTabStop
- sps <- many (char ' ')
- if length sps < tabStop
- then return sps
- else unexpected "indented line"
+ n <- skipNonindentSpaces
+ return $ replicate n ' '
-- returns number of spaces parsed
skipNonindentSpaces :: PandocMonad m => MarkdownParser m Int
skipNonindentSpaces = do
tabStop <- getOption readerTabStop
- atMostSpaces (tabStop - 1) <* notFollowedBy (char ' ')
+ atMostSpaces (tabStop - 1) <* notFollowedBy spaceChar
atMostSpaces :: PandocMonad m => Int -> MarkdownParser m Int
atMostSpaces n