git.iko.soy/typeable/pandoc
on master help sign in
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.

commit2b37ed9f212b711a6381dc89ff7d3431d7c5d916 authorJohn MacFarlane <jgm@berkeley.edu> dateSun 21 Feb 2021, 11:29 (6 years ago) parentdb4f882
1 file changed+5−5
src/Text/Pandoc/Readers/LaTeX/Parsing.hs+5−5
src/Text/Pandoc/Readers/LaTeX/Parsing.hs+5−5
@@ -429,11 +429,11 @@ satisfyTok :: PandocMonad m => (Tok -> Bool) -> LP m Tok
429429satisfyTok f = do
430430 doMacros -- apply macros on remaining input stream
431431 res <- tokenPrim (T.unpack . untoken) updatePos matcher
432− updateState $ \st -> st{ sRawTokens =
433− if sEnableWithRaw st
434− then IntMap.map (res:) $ sRawTokens st
435− else sRawTokens st }
436− return res
432+ updateState $ \st ->
433+ if sEnableWithRaw st
434+ then st{ sRawTokens = IntMap.map (res:) $ sRawTokens st }
435+ else st
436+ return $! res
437437 where matcher t | f t = Just t
438438 | otherwise = Nothing
439439 updatePos :: SourcePos -> Tok -> [Tok] -> SourcePos