From: Alan Mackenzie <acm@muc.de>
To: John Yates <john@yates-sheets.org>
Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
Subject: Re: How can I predict which regions xdisp will present me for font-locking?
Date: Mon, 12 Mar 2012 18:49:09 +0000 [thread overview]
Message-ID: <20120312184909.GA2792@acm.acm> (raw)
In-Reply-To: <CAJnXXoh+zcqHa9iZAAtGstVpKuEffgCiSwz+QGV0JhmgjZHTaA@mail.gmail.com>
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 <eliz@gnu.org> 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))))
+
\f
;; `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).
next prev parent reply other threads:[~2012-03-12 18:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-11 20:59 How can I predict which regions xdisp will present me for font-locking? Alan Mackenzie
2012-03-11 21:45 ` Eli Zaretskii
2012-03-12 17:47 ` John Yates
2012-03-12 18:00 ` Eli Zaretskii
2012-03-13 19:50 ` John Yates
2012-03-13 21:00 ` Alan Mackenzie
2012-03-13 21:18 ` Eli Zaretskii
2012-03-12 18:49 ` Alan Mackenzie [this message]
2012-03-12 19:25 ` Stefan Monnier
2012-03-13 14:05 ` Alan Mackenzie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120312184909.GA2792@acm.acm \
--to=acm@muc.de \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=john@yates-sheets.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).