Subject: bug#24048: 25.0.95; syntax-ppss can be slow

From: Stefan Monnier <[email-masked]>
Date: Fri, 03 Dec 2021 12:01:41 -0500

> In certain situations, the caching of syntax-ppss can seem to be
> insufficient for good performance when syntax-ppss is invoked in
> a tight loop.

Yes, that's a known limitation.  Most uses of `syntax-ppss` that need to
call it in a tight loop move the call outside of the loop and then use
`parse-partial-sexp` inside the loop (and they're careful to move
forward so `parse-partial-sexp` is only called between the last
position and the current one so we avoid re-parsing the same text).

Currently `syntax-ppss` assumes that parsing <2500 chars is "fast
enough" and hence that it's better not to update the "last ppss data"
when this happens (the advantage is that we save time not-updating the
data and we also save time if the next call is somewhere within those
<2500 chars).

        Stefan