aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2021-02-21 11:29:38 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2021-02-21 11:30:17 -0800
commit2b37ed9f212b711a6381dc89ff7d3431d7c5d916 (patch)
treeb340462026db6c9fdc735b7ea6c51518b0cbb266 /src/Text/Pandoc
parentdb4f8823152578d199691f8084fddcc0f04f679b (diff)
downloadpandoc-2b37ed9f212b711a6381dc89ff7d3431d7c5d916.tar.gz
LaTeX reader: further optimizations in satisfyTok.
Benchmarks show 2/3 of the run time and 2/3 of the allocation of the Feb. 10 benchmarks.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX/Parsing.hs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX/Parsing.hs b/src/Text/Pandoc/Readers/LaTeX/Parsing.hs
index 0e098d9d9..c2e10570d 100644
--- a/src/Text/Pandoc/Readers/LaTeX/Parsing.hs
+++ b/src/Text/Pandoc/Readers/LaTeX/Parsing.hs
@@ -429,11 +429,11 @@ satisfyTok :: PandocMonad m => (Tok -> Bool) -> LP m Tok
satisfyTok f = do
doMacros -- apply macros on remaining input stream
res <- tokenPrim (T.unpack . untoken) updatePos matcher
- updateState $ \st -> st{ sRawTokens =
- if sEnableWithRaw st
- then IntMap.map (res:) $ sRawTokens st
- else sRawTokens st }
- return res
+ updateState $ \st ->
+ if sEnableWithRaw st
+ then st{ sRawTokens = IntMap.map (res:) $ sRawTokens st }
+ else st
+ return $! res
where matcher t | f t = Just t
| otherwise = Nothing
updatePos :: SourcePos -> Tok -> [Tok] -> SourcePos