From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: C mode too slow Date: Mon, 13 Jun 2011 14:59:22 +0000 Message-ID: <20110613145922.GA3369@acm.acm> References: <20110612203811.GA10061@acm.acm> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1307977285 12706 80.91.229.12 (13 Jun 2011 15:01:25 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 13 Jun 2011 15:01:25 +0000 (UTC) To: emacs-devel@gnu.org, Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jun 13 17:01:21 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QW8dk-0006NK-W7 for ged-emacs-devel@m.gmane.org; Mon, 13 Jun 2011 17:01:21 +0200 Original-Received: from localhost ([::1]:47217 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QW8dj-0007tM-NX for ged-emacs-devel@m.gmane.org; Mon, 13 Jun 2011 11:01:19 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:52028) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QW8dM-0007sj-2h for emacs-devel@gnu.org; Mon, 13 Jun 2011 11:01:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QW8dH-0000Xs-Pt for emacs-devel@gnu.org; Mon, 13 Jun 2011 11:00:55 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:3017 helo=mail.muc.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QW8dH-0000Xd-BE for emacs-devel@gnu.org; Mon, 13 Jun 2011 11:00:51 -0400 Original-Received: (qmail 24427 invoked by uid 3782); 13 Jun 2011 15:00:48 -0000 Original-Received: from acm.muc.de (pD9557868.dip.t-dialin.net [217.85.120.104]) by colin2.muc.de (tmda-ofmipd) with ESMTP; Mon, 13 Jun 2011 17:00:46 +0200 Original-Received: (qmail 4207 invoked by uid 1000); 13 Jun 2011 14:59:22 -0000 Content-Disposition: inline In-Reply-To: <20110612203811.GA10061@acm.acm> User-Agent: Mutt/1.5.21 (2010-09-15) X-Delivery-Agent: TMDA/1.1.5 (Fettercairn) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 4.6-4.9 X-Received-From: 193.149.48.1 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:140413 Archived-At: Hi, Stefan, On Sun, Jun 12, 2011 at 08:38:11PM +0000, Alan Mackenzie wrote: > >> _and_ because editing lisp.h is virtually impossible these days. I > >> have to use an old Emacs - almost each editing step takes about 15 > >> secs here with the more recent Emacs versions :-( > > I tend to find editing code such as lisp.h too slow as well. Can we > > do something about it? > lisp.h is slow in "brace desserts", since CC Mode uses braces as anchor > points, particularly whilst font locking. This should have been fixed > by the optimisation of c-parse-state. > However, comparing the trunk with Emacs 23.3 the number of calls to > c-parse-state has increased by a factor of ~9, cancelling out the > optimisation. :-( I'm looking to see why this has happened. > I'm actually looking at a large file (without a single brace) called > AT91SAM9263_INC.h, the one which triggered this optimisation. What > seems to me slow in lisp.h is scrolling over areas which haven't yet > been fontified since loading. Once that is done, I think things move at > a decent speed. Is there anything particular, other than initial > scrolling, which is very slow in lisp.h? Could you try editing lisp.h after applying this patch, please, and let me know how it goes: *** cc-fonts.el.~7~ 2011-02-04 22:10:01.000000000 +0000 --- cc-fonts.el 2011-06-13 14:49:30.000000000 +0000 *************** *** 1192,1198 **** ;; Are we at a declarator? Try to go back to the declaration ;; to check this. Note that `c-beginning-of-decl-1' is slow, ;; so we cache its result between calls. ! (let (paren-state bod-res encl-pos is-typedef) (goto-char start-pos) (save-excursion (unless (and decl-search-lim --- 1192,1200 ---- ;; Are we at a declarator? Try to go back to the declaration ;; to check this. Note that `c-beginning-of-decl-1' is slow, ;; so we cache its result between calls. ! (let (paren-state bod-res encl-pos is-typedef ! c-recognize-knr-p) ; Strictly speaking bogus, ! ; but it speeds lisp.h up tremendously. (goto-char start-pos) (save-excursion (unless (and decl-search-lim -- Alan Mackenzie (Nuremberg, Germany).