Markdown reader: Performance improvement in str parser.

Moved a guardEnabled out of an inner loop.
This commit is contained in:
John MacFarlane 2013-01-25 18:42:40 -08:00
parent 71c5ebe682
commit 846be80c26

View file

@ -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')