]> code.delx.au - gnu-emacs/commitdiff
Optimise font locking in long enum definitions.
authorAlan Mackenzie <acm@muc.de>
Sun, 8 Jan 2012 12:49:44 +0000 (12:49 +0000)
committerAlan Mackenzie <acm@muc.de>
Sun, 8 Jan 2012 12:49:44 +0000 (12:49 +0000)
lisp/ChangeLog
lisp/progmodes/cc-fonts.el
lisp/progmodes/cc-langs.el
lisp/progmodes/cc-mode.el

index 9e490a1e367fae6a4a83176f15d254910bfdad16..ab8572b7f935a7f0ace6b40f2ef96f1b1b155b68 100644 (file)
@@ -1,3 +1,12 @@
+2012-01-08  Alan Mackenzie  <acm@muc.de>
+
+       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  <eggert@cs.ucla.edu>
 
        * files.el (move-file-to-trash): Preserve default file modes on error.
index ee5fb1bd0868398dc317a8e2106a8a427b3f7590..f52864df8099a338cd10b945545bd3c6605f0c22 100644 (file)
@@ -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"
index b565cf98b3c71f3dea09bf80ffe00e4dd325e9ee..fafbfb7055290b36a0d4f6d80a973e16391477ef 100644 (file)
@@ -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
index 600d4fc8b560f70b16cdcd837ff9cdbefce500b0..b74d878516dcaa73f24b24fe35ff37c8134fc7c4 100644 (file)
@@ -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>