aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2019-06-16 15:46:12 +0000
committerAlan Mackenzie2019-06-16 15:46:12 +0000
commite6fb9a443f48d7bcf1f56ce2ea526c3fa5b732b0 (patch)
treec310cacba31f57fad289bb0151b2dcc8048da759
parent98ba1c6b52898c5f72f2d6e5c845c8d9386f98f5 (diff)
downloademacs-e6fb9a443f48d7bcf1f56ce2ea526c3fa5b732b0.tar.gz
emacs-e6fb9a443f48d7bcf1f56ce2ea526c3fa5b732b0.zip
CC Mode: Remedy recent loss in performance
* lisp/progmodes/cc-engine.el (c-back-over-member-initializers): call c-parse-state outside of the narrowing operation. * lisp/progmodes/cc-fonts.el (c-get-fontification-context) (c-font-lock-cut-off-declarators): Replace calls to c-determine-limit with crude position calculations for speed.
-rw-r--r--lisp/progmodes/cc-engine.el8
-rw-r--r--lisp/progmodes/cc-fonts.el8
2 files changed, 11 insertions, 5 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 6598cc62c20..d3d7a1c5c0a 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -8611,10 +8611,11 @@ comment at the start of cc-engine.el for more info."
8611 ;; the function's arglist. Otherwise return nil, leaving point unchanged. 8611 ;; the function's arglist. Otherwise return nil, leaving point unchanged.
8612 ;; LIMIT, if non-nil, is a limit for the backward search. 8612 ;; LIMIT, if non-nil, is a limit for the backward search.
8613 (save-restriction 8613 (save-restriction
8614 (if limit (narrow-to-region limit (point)))
8615 (let ((here (point)) 8614 (let ((here (point))
8616 (paren-state (c-parse-state)) 8615 (paren-state (c-parse-state)) ; Do this outside the narrowing for
8616 ; performance reasons.
8617 pos level-plausible at-top-level res) 8617 pos level-plausible at-top-level res)
8618 (if limit (narrow-to-region limit (point)))
8618 ;; Assume tentatively that we're at the top level. Try to go back to the 8619 ;; Assume tentatively that we're at the top level. Try to go back to the
8619 ;; colon we seek. 8620 ;; colon we seek.
8620 (setq res 8621 (setq res
@@ -8637,7 +8638,8 @@ comment at the start of cc-engine.el for more info."
8637 8638
8638 (while (and (not (and level-plausible 8639 (while (and (not (and level-plausible
8639 (setq at-top-level (c-at-toplevel-p)))) 8640 (setq at-top-level (c-at-toplevel-p))))
8640 (setq pos (c-pull-open-brace paren-state))) ; might be a paren. 8641 (setq pos (c-pull-open-brace paren-state)) ; might be a paren.
8642 (or (null limit) (>= pos limit)))
8641 (setq level-plausible 8643 (setq level-plausible
8642 (catch 'level 8644 (catch 'level
8643 (goto-char pos) 8645 (goto-char pos)
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el
index cef2015f430..269d2c90b79 100644
--- a/lisp/progmodes/cc-fonts.el
+++ b/lisp/progmodes/cc-fonts.el
@@ -1204,7 +1204,9 @@ casts and declarations are fontified. Used on level 2 and higher."
1204 ((save-excursion 1204 ((save-excursion
1205 (goto-char match-pos) 1205 (goto-char match-pos)
1206 (and (memq (char-before match-pos) '(?\( ?\,)) 1206 (and (memq (char-before match-pos) '(?\( ?\,))
1207 (c-go-up-list-backward match-pos (c-determine-limit 500)) 1207 (c-go-up-list-backward match-pos
1208 ; c-determine-limit is too slow, here.
1209 (max (- (point) 2000) (point-min)))
1208 (eq (char-after) ?\() 1210 (eq (char-after) ?\()
1209 (let ((type (c-get-char-property (point) 'c-type))) 1211 (let ((type (c-get-char-property (point) 'c-type)))
1210 (or (memq type '(c-decl-arg-start c-decl-type-start)) 1212 (or (memq type '(c-decl-arg-start c-decl-type-start))
@@ -1605,7 +1607,9 @@ casts and declarations are fontified. Used on level 2 and higher."
1605 c-recognize-knr-p) ; Strictly speaking, bogus, but it 1607 c-recognize-knr-p) ; Strictly speaking, bogus, but it
1606 ; speeds up lisp.h tremendously. 1608 ; speeds up lisp.h tremendously.
1607 (save-excursion 1609 (save-excursion
1608 (when (not (c-back-over-member-initializers (c-determine-limit 2000))) 1610 (when (not (c-back-over-member-initializers
1611 (max (- (point) 2000) (point-min)))) ; c-determine-limit
1612 ; is too slow, here.
1609 (unless (or (eobp) 1613 (unless (or (eobp)
1610 (looking-at "\\s(\\|\\s)")) 1614 (looking-at "\\s(\\|\\s)"))
1611 (forward-char)) 1615 (forward-char))