aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 9e490a1e36..ab8572b7f9 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
+2012-01-08 Alan Mackenzie <[email protected]>
+
+ Optimise font locking in long enum definitions.
+
+ * progmodes/cc-fonts.el (c-font-lock-declarations): Add an extra
+ arm to a cond form to handle enums.
+ * progmodes/cc-langs.el (c-enums-contain-decls): New lang variable.
+ * progmodes/cc-mode.el (c-font-lock-fontify-region): Correct a typo.
+
2012-01-07 Paul Eggert <[email protected]>
* 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 ee5fb1bd08..f52864df80 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."
(c-fontify-recorded-types-and-refs)
nil)
+ ((and (not c-enums-contain-decls)
+ ;; An optimisation quickly to eliminate scans of long enum
+ ;; declarations in the next cond arm.
+ (let ((paren-state (c-parse-state)))
+ (and
+ (numberp (car paren-state))
+ (save-excursion
+ (goto-char (car paren-state))
+ (c-backward-token-2)
+ (or (looking-at c-brace-list-key)
+ (progn
+ (c-backward-token-2)
+ (looking-at c-brace-list-key)))))))
+ t)
+
(t
;; Are we at a declarator? Try to go back to the declaration
;; 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 b565cf98b3..fafbfb7055 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -2938,6 +2938,12 @@ expression is considered to be a type."
(consp (c-lang-const c-<>-arglist-kwds))))
(c-lang-defvar c-recognize-<>-arglists (c-lang-const c-recognize-<>-arglists))
+(c-lang-defconst c-enums-contain-decls
+ "Non-nil means that an enum structure can contain declarations."
+ t nil
+ java t)
+(c-lang-defvar c-enums-contain-decls (c-lang-const c-enums-contain-decls))
+
(c-lang-defconst c-recognize-paren-inits
"Non-nil means that parenthesis style initializers exist,
i.e. constructs like
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index 600d4fc8b5..b74d878516 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."
;; Effectively advice around `font-lock-fontify-region' which extends the
;; region (BEG END), for example, to avoid context fontification chopping
;; off the start of the context. Do not do anything if it's already been
- ;; done (i.e. from and after-change fontification. An example (C++) where
+ ;; done (i.e. from an after-change fontification. An example (C++) where
;; this used to happen is this:
;;
;; template <typename T>