aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2012-01-08 12:49:44 +0000
committerAlan Mackenzie2012-01-08 12:49:44 +0000
commit9d5a8f0b3c3fe959d307d5b2f106943aa970c59b (patch)
tree58dae3227ceb01520126cfcc9c89343cf726347c
parent1355012ad77702dc780a378b7e6819d99d076886 (diff)
downloademacs-9d5a8f0b3c3fe959d307d5b2f106943aa970c59b.tar.gz
emacs-9d5a8f0b3c3fe959d307d5b2f106943aa970c59b.zip
Optimise font locking in long enum definitions.
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/progmodes/cc-fonts.el15
-rw-r--r--lisp/progmodes/cc-langs.el6
-rw-r--r--lisp/progmodes/cc-mode.el2
4 files changed, 31 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 9e490a1e367..ab8572b7f93 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
12012-01-08 Alan Mackenzie <acm@muc.de>
2
3 Optimise font locking in long enum definitions.
4
5 * progmodes/cc-fonts.el (c-font-lock-declarations): Add an extra
6 arm to a cond form to handle enums.
7 * progmodes/cc-langs.el (c-enums-contain-decls): New lang variable.
8 * progmodes/cc-mode.el (c-font-lock-fontify-region): Correct a typo.
9
12012-01-07 Paul Eggert <eggert@cs.ucla.edu> 102012-01-07 Paul Eggert <eggert@cs.ucla.edu>
2 11
3 * files.el (move-file-to-trash): Preserve default file modes on error. 12 * files.el (move-file-to-trash): Preserve default file modes on error.
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el
index ee5fb1bd086..f52864df809 100644
--- a/lisp/progmodes/cc-fonts.el
+++ b/lisp/progmodes/cc-fonts.el
@@ -1428,6 +1428,21 @@ casts and declarations are fontified. Used on level 2 and higher."
1428 (c-fontify-recorded-types-and-refs) 1428 (c-fontify-recorded-types-and-refs)
1429 nil) 1429 nil)
1430 1430
1431 ((and (not c-enums-contain-decls)
1432 ;; An optimisation quickly to eliminate scans of long enum
1433 ;; declarations in the next cond arm.
1434 (let ((paren-state (c-parse-state)))
1435 (and
1436 (numberp (car paren-state))
1437 (save-excursion
1438 (goto-char (car paren-state))
1439 (c-backward-token-2)
1440 (or (looking-at c-brace-list-key)
1441 (progn
1442 (c-backward-token-2)
1443 (looking-at c-brace-list-key)))))))
1444 t)
1445
1431 (t 1446 (t
1432 ;; Are we at a declarator? Try to go back to the declaration 1447 ;; Are we at a declarator? Try to go back to the declaration
1433 ;; to check this. If we get there, check whether a "typedef" 1448 ;; to check this. If we get there, check whether a "typedef"
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el
index b565cf98b3c..fafbfb70552 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -2938,6 +2938,12 @@ expression is considered to be a type."
2938 (consp (c-lang-const c-<>-arglist-kwds)))) 2938 (consp (c-lang-const c-<>-arglist-kwds))))
2939(c-lang-defvar c-recognize-<>-arglists (c-lang-const c-recognize-<>-arglists)) 2939(c-lang-defvar c-recognize-<>-arglists (c-lang-const c-recognize-<>-arglists))
2940 2940
2941(c-lang-defconst c-enums-contain-decls
2942 "Non-nil means that an enum structure can contain declarations."
2943 t nil
2944 java t)
2945(c-lang-defvar c-enums-contain-decls (c-lang-const c-enums-contain-decls))
2946
2941(c-lang-defconst c-recognize-paren-inits 2947(c-lang-defconst c-recognize-paren-inits
2942 "Non-nil means that parenthesis style initializers exist, 2948 "Non-nil means that parenthesis style initializers exist,
2943i.e. constructs like 2949i.e. constructs like
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index 600d4fc8b56..b74d878516d 100644
--- a/lisp/progmodes/cc-mode.el
+++ b/lisp/progmodes/cc-mode.el
@@ -1158,7 +1158,7 @@ Note that the style variables are always made local to the buffer."
1158 ;; Effectively advice around `font-lock-fontify-region' which extends the 1158 ;; Effectively advice around `font-lock-fontify-region' which extends the
1159 ;; region (BEG END), for example, to avoid context fontification chopping 1159 ;; region (BEG END), for example, to avoid context fontification chopping
1160 ;; off the start of the context. Do not do anything if it's already been 1160 ;; off the start of the context. Do not do anything if it's already been
1161 ;; done (i.e. from and after-change fontification. An example (C++) where 1161 ;; done (i.e. from an after-change fontification. An example (C++) where
1162 ;; this used to happen is this: 1162 ;; this used to happen is this:
1163 ;; 1163 ;;
1164 ;; template <typename T> 1164 ;; template <typename T>