Subject: Large C++ files load slowly, regardless of font-lock-maximum-size

From: John W <[email-masked]>
Date: Wed, 24 Sep 2008 23:07:19 -0700 (PDT)

To reproduce:
(1) Generate a 3M C++ file.
(2) Load file.
(3) Wait for emacs. <-- bug

I'm using jit-lock, but I tested lazy-lock, and the behavior is the same.

font-lock-maximum-size is the default.  I.e.
Its value is 256000

I used edebug to see what emacs was doing, and it gave me a stack like:

  c-literal-limits()
  c-neutralize-syntax-in-CPP(1 3527391 3527390)
  funcall(c-neutralize-syntax-in-CPP 1 3527391 3527390)
  (if nil c-before-font-lock-function (funcall c-before-font-lock-function (point-min) (point-max) (- ... ...)))
  (save-excursion (if c-get-state-before-change-function (funcall c-get-state-before-change-function ... ...)) (if nil c-before-font-lock-function (funcall c-before-font-lock-function ... ... ...)))
  (save-restriction (widen) (save-excursion (if c-get-state-before-change-function ...) (if nil c-before-font-lock-function ...)))
  c-common-init(c++-mode)
  c++-mode()
  set-auto-mode-0(c++-mode nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(nil t)

I blame c-before-font-lock-function .

If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
    `bt full' and `xbacktrace'.
If you would like to further debug the crash, please read the file
/usr/local/share/emacs/22.2/etc/DEBUG for instructions.

In GNU Emacs 22.2.1 (i686-pc-linux-gnu)
 of 2008-08-27 on augustine
Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: C
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.utf8
  locale-coding-system: utf-8
  default-enable-multibyte-characters: t

Major mode: Emacs-Lisp

Minor modes in effect:
  encoded-kbd-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  unify-8859-on-encoding-mode: t
  utf-translate-cjk-mode: t
  auto-compression-mode: t
  line-number-mode: t

Recent input:
[ 6 ~ ESC [ 6 ~ ESC [ 6 ~ ESC [ 6 ~ ESC [ 6 ~ ESC [ 
6 ~ ESC [ 5 ~ ESC [ 5 ~ ESC [ 5 ~ ESC [ 5 ~ ESC [ 5 
~ ESC [ 5 ~ ESC [ 5 ~ ESC [ 5 ~ ESC [ 5 ~ ESC [ 5 ~ 
ESC [ 5 ~ ESC [ 5 ~ C-x k RET C-x C-e C-x k RET ESC 
[ A ESC [ A ESC [ A ESC [ A ESC [ A ESC [ A ESC [ A 
ESC [ A ESC [ A ESC [ A ESC [ A ESC [ A ESC [ A ESC 
[ A ESC [ A ESC [ A ESC [ A ESC [ A ESC [ B ESC [ B 
ESC [ B ESC [ A ESC f ESC f ESC f ESC f ESC f ESC b 
C-k C-_ ESC [ 5 ~ ESC [ 6 ~ ESC [ 5 ~ ESC [ 6 ~ ESC 
[ B ESC [ B ESC [ B ESC [ B ESC [ B ESC [ B ESC [ B 
ESC [ B ESC [ B ESC [ B ESC [ A C-@ ESC [ B ESC [ B 
ESC [ B C-x b C-g C-x o C-g ESC [ A ESC [ A ESC [ A 
ESC f ESC f ESC b ESC f ESC f ESC f ESC f ESC b C-k 
C-_ C-x b RET C-x b RET ESC x e m a c s - b DEL d e 
TAB DEL DEL TAB DEL DEL DEL DEL DEL DEL b u TAB DEL 
DEL g n TAB DEL DEL DEL DEL r e p o TAB r t TAB RE
T

Recent messages:
#<buffer Connect.i>
Auto-saving...done
Undo!
Mark set
Entering debugger...
Quit
Undo!
Auto-saving...done
Making completion list... [3 times]
Loading emacsbug...done