[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How can I predict which regions xdisp will present me for font-locki
From: |
Alan Mackenzie |
Subject: |
Re: How can I predict which regions xdisp will present me for font-locking? |
Date: |
Mon, 12 Mar 2012 18:49:09 +0000 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Hello again, John.
On Mon, Mar 12, 2012 at 01:47:00PM -0400, John Yates wrote:
> On Sun, Mar 11, 2012 at 5:45 PM, Eli Zaretskii <address@hidden> wrote:
> >> Date: Sun, 11 Mar 2012 20:59:03 +0000
[ .... ]
> I am seeing a horrendous slowdown when editing atypical macros (though
> no more than 50 lines long). Worse still I see the same slowdown when
> editing a comment if even a fragment of my atypical macro is visible.
What does horrendous mean? It could mean 10s per key (i.e. totally
broken) or ¼s per key (very sluggish). Is the horrenditity any worse
typing the comma?
> The pattern of the macro is
> #define LIST_NAME \
> _ROW_( <literal columns> ) \
> , _ROW_( <literal columns> ) \
> ... \
> , _ROW_( <literal columns> ) \
Here's an update to the latest current state of my optimisations. Try it
out, please, and see if it make things any better.
=== modified file 'lisp/progmodes/cc-engine.el'
*** lisp/progmodes/cc-engine.el 2012-03-02 22:16:21 +0000
--- lisp/progmodes/cc-engine.el 2012-03-12 18:32:00 +0000
***************
*** 1246,1252 ****
(c-at-vsemi-p))))
(throw 'done vsemi-pos))
;; In a string/comment?
! ((setq lit-range (c-literal-limits))
(goto-char (cdr lit-range)))
((eq (char-after) ?:)
(forward-char)
--- 1246,1252 ----
(c-at-vsemi-p))))
(throw 'done vsemi-pos))
;; In a string/comment?
! ((setq lit-range (c-literal-limits from))
(goto-char (cdr lit-range)))
((eq (char-after) ?:)
(forward-char)
***************
*** 3250,3257 ****
(if scan-forward-p
(progn (narrow-to-region (point-min) here)
(c-append-to-state-cache good-pos))
!
! (c-get-cache-scan-pos good-pos))))
(t ; (eq strategy 'IN-LIT)
(setq c-state-cache nil
--- 3250,3256 ----
(if scan-forward-p
(progn (narrow-to-region (point-min) here)
(c-append-to-state-cache good-pos))
! good-pos)))
(t ; (eq strategy 'IN-LIT)
(setq c-state-cache nil
***************
*** 4563,4568 ****
--- 4562,4599 ----
(point-min))
(t
(c-determine-limit (- how-far-back count) base try-size))))))
+
+ (defun c-determine-+ve-limit (how-far &optional start-pos)
+ ;; Return a buffer position about HOW-FAR non-literal characters forward
+ ;; from START-POS (default point), which must not be inside a literal.
+ (save-excursion
+ (let ((pos (or start-pos (point)))
+ (count how-far)
+ (s (parse-partial-sexp (point) (point)))) ; null state
+ (while (and (not (eobp))
+ (> count 0))
+ ;; Scan over counted characters.
+ (setq s (parse-partial-sexp
+ pos
+ (min (+ pos count) (point-max))
+ nil ; target-depth
+ nil ; stop-before
+ s ; state
+ 'syntax-table)) ; stop-comment
+ (setq count (- count (- (point) pos) 1)
+ pos (point))
+ ;; Scan over literal characters.
+ (if (nth 8 s)
+ (setq s (parse-partial-sexp
+ pos
+ (point-max)
+ nil ; target-depth
+ nil ; stop-before
+ s ; state
+ 'syntax-table) ; stop-comment
+ pos (point))))
+ (point))))
+
;; `c-find-decl-spots' and accompanying stuff.
***************
*** 8635,8641 ****
(setq pos (point)))
(and
c-macro-with-semi-re
- (not (c-in-literal))
(eq (skip-chars-backward " \t") 0)
;; Check we've got nothing after this except comments and empty lines
--- 8666,8671 ----
***************
*** 8666,8672 ****
(c-backward-syntactic-ws)
t))
(c-simple-skip-symbol-backward)
! (looking-at c-macro-with-semi-re)))))
(defun c-macro-vsemi-status-unknown-p () t) ; See cc-defs.el.
--- 8696,8704 ----
(c-backward-syntactic-ws)
t))
(c-simple-skip-symbol-backward)
! (looking-at c-macro-with-semi-re)
! (goto-char pos)
! (not (c-in-literal)))))) ; The most expensive check
last.
(defun c-macro-vsemi-status-unknown-p () t) ; See cc-defs.el.
***************
*** 9571,9577 ****
;; CASE 5B: After a function header but before the body (or
;; the ending semicolon if there's no body).
((save-excursion
! (when (setq placeholder (c-just-after-func-arglist-p lim))
(setq tmp-pos (point))))
(cond
--- 9603,9610 ----
;; CASE 5B: After a function header but before the body (or
;; the ending semicolon if there's no body).
((save-excursion
! (when (setq placeholder (c-just-after-func-arglist-p
! (max lim (c-determine-limit 500))))
(setq tmp-pos (point))))
(cond
=== modified file 'lisp/progmodes/cc-mode.el'
*** lisp/progmodes/cc-mode.el 2012-02-22 19:34:32 +0000
--- lisp/progmodes/cc-mode.el 2012-03-12 18:31:49 +0000
***************
*** 925,932 ****
;; inside a string, comment, or macro.
(setq new-bounds (c-extend-font-lock-region-for-macros
c-new-BEG c-new-END old-len))
! (setq c-new-BEG (car new-bounds)
! c-new-END (cdr new-bounds))
;; Clear all old relevant properties.
(c-clear-char-property-with-value c-new-BEG c-new-END 'syntax-table '(1))
(c-clear-char-property-with-value c-new-BEG c-new-END 'category
'c-cpp-delimiter)
--- 925,932 ----
;; inside a string, comment, or macro.
(setq new-bounds (c-extend-font-lock-region-for-macros
c-new-BEG c-new-END old-len))
! (setq c-new-BEG (max (car new-bounds) (c-determine-limit 500 begg))
! c-new-END (min (cdr new-bounds) (c-determine-+ve-limit 500 endd)))
;; Clear all old relevant properties.
(c-clear-char-property-with-value c-new-BEG c-new-END 'syntax-table '(1))
(c-clear-char-property-with-value c-new-BEG c-new-END 'category
'c-cpp-delimiter)
> /john
--
Alan Mackenzie (Nuremberg, Germany).
Re: How can I predict which regions xdisp will present me for font-locking?, Stefan Monnier, 2012/03/12