diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2022-03-31 10:08:44 -0700 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2022-03-31 10:11:48 -0700 |
| commit | 8b21ec7d0cc43cdcee3fa4cc981e10e34f59f217 (patch) | |
| tree | cac73dfdeaa8ca3fc1f831dc98667fe48e18d4c5 | |
| parent | ad726953b9cb7d2bf164ec091227872e97cf8f65 (diff) | |
Markdown reader: add some strictness.
This improves some benchmarks significantly.
| -rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 4e0a1fa6a..63a69774b 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -1,4 +1,5 @@ {-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE BangPatterns #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE TupleSections #-} {-# LANGUAGE OverloadedStrings #-} @@ -1724,7 +1725,7 @@ nonEndline = satisfy (/='\n') str :: PandocMonad m => MarkdownParser m (F Inlines) str = do - result <- mconcat <$> many1 + !result <- mconcat <$> many1 ( T.pack <$> (many1 alphaNum) <|> "." <$ try (char '.' <* notFollowedBy (char '.')) ) updateLastStrPos @@ -1740,11 +1741,11 @@ str = do ils' <- ils case B.toList ils' of [Space] -> - return (B.str result <> B.str "\160") - _ -> return (B.str result <> ils')) - <|> return (return (B.str result)) - else return (return (B.str result))) - <|> return (return (B.str result)) + return $! (B.str result <> B.str "\160") + _ -> return $! (B.str result <> ils')) + <|> return (return $! B.str result) + else return (return $! B.str result)) + <|> return (return $! B.str result) -- an endline character that can be treated as a space, not a structural break endline :: PandocMonad m => MarkdownParser m (F Inlines) |
