[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Emacs-diffs] comment-cache 223d16f 2/3: Apply `comment-depth' text

From: Stefan Monnier
Subject: Re: [Emacs-diffs] comment-cache 223d16f 2/3: Apply `comment-depth' text properties when calling `back_comment'.
Date: Sun, 13 Mar 2016 21:30:27 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

> Yes, it would be fast. But like we've noticed, calling syntax-ppss is also
> quick, and it basically has a constant upper bound, on average. It's hard to
> be *significantly* faster than that.

> So I have to wonder why the "get out of a comment" feature is used in C/l
> mode so much that it becomes a bottleneck, and you get significant
> improvement in performance by dropping the caching logic to C. That is, of
> course, not a nice thing to ask considering the overall complexity of CC
> Mode, but still.

Hmm... I get the impression that maybe there's some confusion here.
The current "get out of a comment" feature doesn't use syntax-ppss.

It parses comments backward using ad-hoc logic to handle the (hopefully)
common cases that *can* be handled.  But in some cases, you can't really
parse comments backward and you need to jump back to a "safe spot"
(outside of comments/strings) and parse forward from there.  In the
current Emacs code this "safe spot" is either point-min or the nearest
open-paren-in-column-0.  syntax-ppss could provide this safe spot, of
course, but we don't do that yet (that's what my patch does).

> I don't see anything comparable to 10 second waiting described in
> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=22884, when doing a comparable
> operation in a 5000-line Ruby file.

Ruby's comment syntax is easier to parse backward than C's (because
there's only one syntax style, rather than 2), so it will not fallback
on the forward parsing as often as in C.  Maybe that's part of the
explanation.  Then again, maybe it has nothing to do with it, and
depends on specifics of CC-mode.  I don't know enough about what Emacs
is doing during those famous 10s.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]