From: Alan Mackenzie <acm@muc.de>
To: Dmitry Antipov <dmantipov@yandex.ru>
Cc: Eli Zaretskii <eliz@gnu.org>,
Stefan Monnier <monnier@iro.umontreal.ca>,
emacs-devel@gnu.org
Subject: Re: Scrolling huge buffers and cc-mode
Date: Thu, 20 Dec 2012 22:29:43 +0000 [thread overview]
Message-ID: <20121220222943.GA2895@acm.acm> (raw)
In-Reply-To: <50D16AD7.5060005@yandex.ru>
Hello, Dmitry,
On Wed, Dec 19, 2012 at 11:20:55AM +0400, Dmitry Antipov wrote:
> It looks like the reason of slow scrolling is how the C++ namespaces are handled.
> Basically my test file is:
> namespace X {
> namespace Y {
> /* 13K lines of code */
> } }
> /* middle-point */
> namespace X { <==============================================
> namespace Y {
> /* 13K lines of code */
> } }
> When scrolling reaches middle-point, everything hangs, most probably because
> we need to scan huge regions (first and second namespace blocks). When I remove
> all namespace definitions (with matched '}'), scrolling works much faster.
What is happening is that (c-beginning-of-statement-1 ...) is being
called repeatedly on the <===== line.
o - This moves to the beginning of "namespace X {",
o - then calls (scan-sexps (point) -1),
o - which has to scan over the 13k lines of code. This is slow.
The solution appears to be to give the backward search a search limit.
Could you try out the following patch please, and let me know if it works
OK:
diff -r ce04d3763229 cc-fonts.el
--- a/cc-fonts.el Thu Dec 20 20:11:22 2012 +0000
+++ b/cc-fonts.el Thu Dec 20 21:58:50 2012 +0000
@@ -1558,6 +1558,7 @@
;; prevent a repeat invocation. See elisp/lispref page "Search-based
;; Fontification".
(let* ((paren-state (c-parse-state))
+ (decl-search-lim (c-determine-limit 1000))
decl-context in-typedef ps-elt)
;; Are we in any nested struct/union/class/etc. braces?
(while paren-state
@@ -1566,7 +1567,7 @@
(when (and (atom ps-elt)
(eq (char-after ps-elt) ?\{))
(goto-char ps-elt)
- (setq decl-context (c-beginning-of-decl-1)
+ (setq decl-context (c-beginning-of-decl-1 decl-search-lim)
in-typedef (looking-at c-typedef-key))
(if in-typedef (c-forward-token-2))
(when (and c-opt-block-decls-with-vars-key
> Dmitry
--
Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2012-12-20 22:29 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-18 9:56 Scrolling huge buffers and cc-mode Dmitry Antipov
2012-12-18 17:30 ` Eli Zaretskii
2012-12-18 19:58 ` Stefan Monnier
2012-12-19 6:04 ` Dmitry Antipov
2012-12-19 7:20 ` Dmitry Antipov
2012-12-19 22:39 ` Alan Mackenzie
2012-12-20 0:52 ` Michael Welsh Duggan
2012-12-20 22:29 ` Alan Mackenzie [this message]
2012-12-21 5:15 ` Dmitry Antipov
2012-12-21 10:57 ` Alan Mackenzie
2012-12-22 3:28 ` Chong Yidong
2012-12-18 19:40 ` Stefan Monnier
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121220222943.GA2895@acm.acm \
--to=acm@muc.de \
--cc=dmantipov@yandex.ru \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.