Subject: bug#11545: 24.0.96-mac-2.92; Strange speed problem scrolling in C++ code

From: Alan Mackenzie <[email-masked]>
Date: Fri, 25 May 2012 21:45:47 +0000

Hello John,

On Wed, May 23, 2012 at 05:28:24AM -0500, John Wiegley wrote:
> >>>>> Glenn Morris <[email-masked]> writes:

> > I see hundreds of lines of differences between the emacs-23 and emacs-24
> > branch versions of cc-fonts.

> Sorry, tool failure here.  Now I'm seeing:

>     660 insertions(+), 243 deletions(-)

> > PS The context for this bug report is missing; but I imagine the first thing
> > Alan will ask for is an example that shows how to reproduce the problem.

> Start either Emacs with -Q -nw.  Open a largish C++ file.  Hold down C-v.  On
> my laptop the lagginess was quite obvious, on my desktop a little less so.

This has been the case for some while, as you have said.

The offending function is probably c-font-lock-enclosing-decls, a
relatively new function.  c-f-l-e-decls solves the former problem of
misfontification when a jit-lock chunk started within (mainly) a
struct/enum/union/class/... and lacked the context to fontify correctly.
An example of this happening was the first enum construct in
.../emacs/src/gnutls.h.

Could you possibly check this is the case in your file.c++ using elp.
Here's a quick recipe in case you haven't used it before:
[ M-x elp-instrument-package <ret> c- <ret>.
  Scroll with C-v, either once or an arbitrary number of times.
  M-x elp-results.]

The cost of this correct fontification is the "slight" sluggishness being
seen here.  It is likely possible to optimise this function somewhat,
though probably it's now too late for Emacs 24.1.

> Thanks, John

-- 
Alan Mackenzie (Nuremberg, Germany).