diff options
author | Alan Mackenzie <acm@muc.de> | 2016-03-14 21:44:11 +0000 |
---|---|---|
committer | Alan Mackenzie <acm@muc.de> | 2016-03-14 21:48:45 +0000 |
commit | 5cc691930808ccf7afdbc53ed49ca24badd97013 (patch) | |
tree | f986652c247488eb6c2d09d2db388599e206256e /lisp/progmodes/cc-defs.el | |
parent | 0ce37eac45f8b1279e89e854f71bb3f35fd43d29 (diff) | |
download | emacs-5cc691930808ccf7afdbc53ed49ca24badd97013.tar.gz emacs-5cc691930808ccf7afdbc53ed49ca24badd97013.tar.bz2 emacs-5cc691930808ccf7afdbc53ed49ca24badd97013.zip |
Fix a cacheing bug, which led to inordinately slow c-beginning-of-defun.
* lisp/progmodes/cc-defs.el (c-self-bind-state-cache): New macro.
* lisp/progmodes/cc-engine.el (c-ssb-lit-begin): Always call c-parse-state
rather than just using the cache variable c-state-cache.
(c-syntactic-skip-backward): Invoke c-self-bind-state-cache to isolate calls
to c-parse-state from other uses of the parse state cache.
* lisp/progmodes/cc-cmds.el (c-beginning-of-defun, c-end-of-defun): Invoke
c-self-bind-state-cache around the processing, replacing flawed bindings of
c-state-cache.
Diffstat (limited to 'lisp/progmodes/cc-defs.el')
-rw-r--r-- | lisp/progmodes/cc-defs.el | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el index 000995c5b53..3b9f44e55a0 100644 --- a/lisp/progmodes/cc-defs.el +++ b/lisp/progmodes/cc-defs.el @@ -1258,7 +1258,8 @@ been put there by c-put-char-property. POINT remains unchanged." (def-edebug-spec c-clear-char-property t) (def-edebug-spec c-clear-char-properties t) (def-edebug-spec c-put-overlay t) -(def-edebug-spec c-delete-overlay t) ;)) +(def-edebug-spec c-delete-overlay t) +(def-edebug-spec c-self-bind-state-cache t);)) ;;; Functions. @@ -1397,6 +1398,26 @@ been put there by c-put-char-property. POINT remains unchanged." (save-restriction (widen) (c-set-cpp-delimiters ,beg ,end))))) + +(defmacro c-self-bind-state-cache (&rest forms) + ;; Bind the state cache to itself and execute the FORMS. It is assumed that no + ;; buffer changes will happen in FORMS, and no hidden buffer changes which could + ;; affect the parsing will be made by FORMS. + `(let ((c-state-cache (copy-tree c-state-cache)) + (c-state-cache-good-pos c-state-cache-good-pos) + ;(c-state-nonlit-pos-cache (copy-tree c-state-nonlit-pos-cache)) + ;(c-state-nonlit-pos-cache-limit c-state-nonlit-pos-cache-limit) + ;(c-state-semi-nonlit-pos-cache (copy-treec c-state-semi-nonlit-pos-cache)) + ;(c-state-semi-nonlit-pos-cache-limit c-state-semi-nonlit-pos-cache) + (c-state-brace-pair-desert (copy-tree c-state-brace-pair-desert)) + (c-state-point-min c-state-point-min) + (c-state-point-min-lit-type c-state-point-min-lit-type) + (c-state-point-min-lit-start c-state-point-min-lit-start) + (c-state-min-scan-pos c-state-min-scan-pos) + (c-state-old-cpp-beg c-state-old-cpp-beg) + (c-state-old-cpp-end c-state-old-cpp-end)) + ,@forms)) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; The following macros are to be used only in `c-parse-state' and its |