Subject: Re: bug#40052: CC Mode 5.34 (C++//l); cc-mode hangs fontifying src/hotspot/share/runtime/globals.hpp in OpenJDK

From: Nick Gasson <[email-masked]>
Date: Wed, 22 Apr 2020 12:11:18 +0800

>
> OK, thanks.  I've had another look into CC Mode, and found a bug in the
> handling of its macro cache.  It isn't saving the position of the end of
> the macro, hence is doing too much scanning.
>
> I've fixed this in the following patch, which gives another factor of ~5
> speedup in the scrolling.  Please remove the previous patch before
> applying this new one.
>
> However, the scrolling still gets sluggish towards the end of
> globals.hpp.  This is because CC Mode's function which goes back to the
> beginning of a statement is scanning back over the entire macro.  It
> basically looks for semicolons or closing braces (at top level) and
> there are none in the huge macro.  I tried creating a variant of
> globals.hpp, where each "function call" was terminated by a semicolon.
> The sluggishness was entirely fixed.  This is largely theoretical, as I
> assume you have no control over the contents of globals.hpp.
>
> Anyhow, here is the patch.  Please let me know if there are still
> problems with it.  Thanks!
>

Hi Alan,

I tried the second patch and it's working well. Thanks again.

There was some discussion of getting rid of the giant macro on the
OpenJDK mailing list. That's when I realised several other people had
the same problem opening that file in Emacs.

https://mail.openjdk.java.net/pipermail/hotspot-dev/2020-March/041088.html

Nick