git.iko.soy/typeable/pandoc
on master help sign in
Performance improvements:

+ Rearranged parsers in definition of 'inline' so that the most frequently used would (by and large) be tried first. + Removed some unneeded 'try's. + Removed tabchar parser, as whitespace handles tabs anyway. + All in all, these changes, together with the last two commits, cut almost in half the time it takes pandoc to parse a large test file. git-svn-id: https://pandoc.googlecode.com/svn/trunk@924 788f1e2b-df1e-0410-8736-df70ead52e1b

commit1d8fe2653a7e67da06c15588a5940b20b0d8587e authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateTue 28 Aug 2007, 02:33 (19 years ago) parent08fbfa3
1 file changed+11−13
src/Text/Pandoc/Readers/Markdown.hs+11−13
src/Text/Pandoc/Readers/Markdown.hs+11−13
@@ -617,6 +617,11 @@ table = failIfStrict >> (simpleTable <|> multilineTable) <?> "table"
617617
618618inline = choice [ rawLaTeXInline'
619619 , escapedChar
620+ , smartPunctuation
621+ , linebreak
622+ , endline
623+ , whitespace
624+ , str
620625 , charRef
621626 , note
622627 , inlineNote
@@ -631,15 +636,9 @@ inline = choice [ rawLaTeXInline'
631636 , strikeout
632637 , superscript
633638 , subscript
634− , smartPunctuation
635639 , code
636− , ltSign
637640 , symbol
638− , str
639− , linebreak
640− , tabchar
641− , whitespace
642− , endline ] <?> "inline"
641+ , ltSign ] <?> "inline"
643642
644643escapedChar = try $ do
645644 char '\\'
@@ -649,10 +648,11 @@ escapedChar = try $ do
649648 else satisfy (not . isAlphaNum)
650649 return $ Str [result]
651650
652−ltSign = try $ do
653− notFollowedBy (noneOf "<") -- continue only if it's a <
654− notFollowedBy' rawHtmlBlocks -- don't return < if it starts html
655− char '<'
651+ltSign = do
652+ st <- getState
653+ if stateStrict st
654+ then char '<'
655+ else notFollowedBy' rawHtmlBlocks >> char '<' -- unless it starts html
656656 return $ Str ['<']
657657
658658specialCharsMinusLt = filter (/= '<') specialChars
@@ -760,8 +760,6 @@ emDash = try $ skipSpaces >> oneOfStrings ["---", "--"] >>
760760
761761whitespace = (many1 (oneOf spaceChars) >> return Space) <?> "whitespace"
762762
763−tabchar = tab >> return (Str "\t")
764−
765763-- hard line break
766764linebreak = try $ oneOf spaceChars >> many1 (oneOf spaceChars) >>
767765 endline >> return LineBreak