[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r102076: progmodes/cc-fonts.el (c-fon
From: |
Alan Mackenzie |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r102076: progmodes/cc-fonts.el (c-font-lock-declarations): Cache the result of |
Date: |
Sun, 24 Oct 2010 15:27:37 +0000 |
User-agent: |
Bazaar (2.0.3) |
------------------------------------------------------------
revno: 102076
committer: Alan Mackenzie <address@hidden>
branch nick: trunk
timestamp: Sun 2010-10-24 15:27:37 +0000
message:
progmodes/cc-fonts.el (c-font-lock-declarations): Cache the result of
`c-beginning-of-decl-1' between invocations of a lambda function (Bug
#7265).
modified:
lisp/ChangeLog
lisp/progmodes/cc-fonts.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2010-10-24 03:12:17 +0000
+++ b/lisp/ChangeLog 2010-10-24 15:27:37 +0000
@@ -1,3 +1,9 @@
+2010-10-24 Alan Mackenzie <address@hidden>
+
+ * progmodes/cc-fonts.el (c-font-lock-declarations): Cache the
+ result of `c-beginning-of-decl-1' between invocations of a lambda
+ function (Bug #7265).
+
2010-10-24 Daiki Ueno <address@hidden>
* epg-config.el (epg-gpg-program): Try to use "gpg2" if "gpg"
=== modified file 'lisp/progmodes/cc-fonts.el'
--- a/lisp/progmodes/cc-fonts.el 2010-10-09 19:58:28 +0000
+++ b/lisp/progmodes/cc-fonts.el 2010-10-24 15:27:37 +0000
@@ -1045,6 +1045,9 @@
;; The position of the next token after the closing paren of
;; the last detected cast.
last-cast-end
+ ;; Start of containing declaration (if any); limit for searching
+ ;; backwards for it.
+ decl-start decl-search-lim
;; The result from `c-forward-decl-or-cast-1'.
decl-or-cast
;; The maximum of the end positions of all the checked type
@@ -1184,20 +1187,29 @@
match-pos context last-cast-end))
(if (not decl-or-cast)
- ;; Are we at a declarator?
- ;; Try to go back to the declaration to check this.
- (let (paren-state bod-res lim encl-pos is-typedef)
+ ;; Are we at a declarator? Try to go back to the declaration
+ ;; to check this. Note that `c-beginning-of-decl-1' is slow,
+ ;; so we cache its result between calls.
+ (let (paren-state bod-res encl-pos is-typedef)
(goto-char start-pos)
(save-excursion
- (setq lim (and (c-syntactic-skip-backward "^;" nil t)
- (point))))
+ (unless (and decl-search-lim
+ (eq decl-search-lim
+ (save-excursion
+ (c-syntactic-skip-backward "^;" nil t)
+ (point))))
+ (setq decl-search-lim
+ (and (c-syntactic-skip-backward "^;" nil t)
(point)))
+ (setq bod-res (car (c-beginning-of-decl-1
decl-search-lim)))
+ (if (and (eq bod-res 'same)
+ (progn
+ (c-backward-syntactic-ws)
+ (eq (char-before) ?\})))
+ (c-beginning-of-decl-1 decl-search-lim))
+ (setq decl-start (point))))
+
(save-excursion
- (setq bod-res (car (c-beginning-of-decl-1 lim)))
- (if (and (eq bod-res 'same)
- (progn
- (c-backward-syntactic-ws)
- (eq (char-before) ?\})))
- (c-beginning-of-decl-1 lim))
+ (goto-char decl-start)
;; We're now putatively at the declaration.
(setq paren-state (c-parse-state))
;; At top level or inside a "{"?
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r102076: progmodes/cc-fonts.el (c-font-lock-declarations): Cache the result of,
Alan Mackenzie <=