From 846be80c268697a3ee07a292db6dd78208aaabe2 Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Fri, 25 Jan 2013 18:42:40 -0800 Subject: [PATCH] Markdown reader: Performance improvement in str parser. Moved a guardEnabled out of an inner loop. --- src/Text/Pandoc/Readers/Markdown.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 235b594db..558043b3c 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -1422,11 +1422,14 @@ nonEndline = satisfy (/='\n') str :: MarkdownParser (F Inlines) str = do - isSmart <- readerSmart . stateOptions <$> getState + isSmart <- getOption readerSmart + intrawordUnderscores <- option False $ + True <$ guardEnabled Ext_intraword_underscores a <- alphaNum as <- many $ alphaNum - <|> (guardEnabled Ext_intraword_underscores >> - try (char '_' >>~ lookAhead alphaNum)) + <|> (if intrawordUnderscores + then try (char '_' >>~ lookAhead alphaNum) + else mzero) <|> if isSmart then (try $ satisfy (\c -> c == '\'' || c == '\x2019') >> lookAhead alphaNum >> return '\x2019')