[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master e6fb9a4: CC Mode: Remedy recent loss in performance
From: |
Alan Mackenzie |
Subject: |
[Emacs-diffs] master e6fb9a4: CC Mode: Remedy recent loss in performance |
Date: |
Sun, 16 Jun 2019 11:48:58 -0400 (EDT) |
branch: master
commit e6fb9a443f48d7bcf1f56ce2ea526c3fa5b732b0
Author: Alan Mackenzie <address@hidden>
Commit: Alan Mackenzie <address@hidden>
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.
---
lisp/progmodes/cc-engine.el | 8 +++++---
lisp/progmodes/cc-fonts.el | 8 ++++++--
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 6598cc6..d3d7a1c 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."
;; the function's arglist. Otherwise return nil, leaving point unchanged.
;; LIMIT, if non-nil, is a limit for the backward search.
(save-restriction
- (if limit (narrow-to-region limit (point)))
(let ((here (point))
- (paren-state (c-parse-state))
+ (paren-state (c-parse-state)) ; Do this outside the narrowing for
+ ; performance reasons.
pos level-plausible at-top-level res)
+ (if limit (narrow-to-region limit (point)))
;; Assume tentatively that we're at the top level. Try to go back to the
;; colon we seek.
(setq res
@@ -8637,7 +8638,8 @@ comment at the start of cc-engine.el for more info."
(while (and (not (and level-plausible
(setq at-top-level (c-at-toplevel-p))))
- (setq pos (c-pull-open-brace paren-state))) ; might
be a paren.
+ (setq pos (c-pull-open-brace paren-state)) ; might be
a paren.
+ (or (null limit) (>= pos limit)))
(setq level-plausible
(catch 'level
(goto-char pos)
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el
index cef2015..269d2c9 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."
((save-excursion
(goto-char match-pos)
(and (memq (char-before match-pos) '(?\( ?\,))
- (c-go-up-list-backward match-pos (c-determine-limit 500))
+ (c-go-up-list-backward match-pos
+ ; c-determine-limit is too slow, here.
+ (max (- (point) 2000) (point-min)))
(eq (char-after) ?\()
(let ((type (c-get-char-property (point) 'c-type)))
(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."
c-recognize-knr-p) ; Strictly speaking, bogus, but it
; speeds up lisp.h tremendously.
(save-excursion
- (when (not (c-back-over-member-initializers (c-determine-limit 2000)))
+ (when (not (c-back-over-member-initializers
+ (max (- (point) 2000) (point-min)))) ; c-determine-limit
+ ; is too slow, here.
(unless (or (eobp)
(looking-at "\\s(\\|\\s)"))
(forward-char))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master e6fb9a4: CC Mode: Remedy recent loss in performance,
Alan Mackenzie <=