[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Scrolling huge buffers and cc-mode
From: |
Alan Mackenzie |
Subject: |
Re: Scrolling huge buffers and cc-mode |
Date: |
Thu, 20 Dec 2012 22:29:43 +0000 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
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).
Re: Scrolling huge buffers and cc-mode, Stefan Monnier, 2012/12/18