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: Slow fontification in C mode buffers Date: Fri, 6 Jan 2012 22:08:06 +0000 Message-ID: <20120106220806.GA3217@acm.acm> References: <87pqfso5d3.fsf@isil.kanru.info> <20111215134332.GA5698@acm.acm> <87y5udizdy.fsf@isil.kanru.info> <20111215181215.GA3464@acm.acm> <87ty51i6vf.fsf@isil.kanru.info> <20111216112617.GA3445@acm.acm> <87pqfngp3r.fsf@isil.kanru.info> <20111221105626.GA3263@acm.acm> <87ehvwxd8g.fsf@nifty.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1325888087 15153 80.91.229.12 (6 Jan 2012 22:14:47 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 6 Jan 2012 22:14:47 +0000 (UTC) Cc: Kan-Ru Chen , emacs-devel@gnu.org To: Kentaro NAKAZAWA Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jan 06 23:14:43 2012 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 1RjI3e-0005ax-Cd for ged-emacs-devel@m.gmane.org; Fri, 06 Jan 2012 23:14:42 +0100 Original-Received: from localhost ([::1]:38609 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RjI3d-0003un-SA for ged-emacs-devel@m.gmane.org; Fri, 06 Jan 2012 17:14:41 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:36423) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RjI3a-0003uF-GB for emacs-devel@gnu.org; Fri, 06 Jan 2012 17:14:39 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RjI3Z-00030P-96 for emacs-devel@gnu.org; Fri, 06 Jan 2012 17:14:38 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:18900 helo=mail.muc.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RjI3Y-00030F-So for emacs-devel@gnu.org; Fri, 06 Jan 2012 17:14:37 -0500 Original-Received: (qmail 13726 invoked by uid 3782); 6 Jan 2012 22:14:34 -0000 Original-Received: from acm.muc.de (pD9557F11.dip.t-dialin.net [217.85.127.17]) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 06 Jan 2012 23:14:33 +0100 Original-Received: (qmail 761 invoked by uid 1000); 6 Jan 2012 22:08:06 -0000 Content-Disposition: inline In-Reply-To: <87ehvwxd8g.fsf@nifty.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. 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:147416 Archived-At: Hello, Kentaro. On Fri, Dec 23, 2011 at 10:56:15AM +0900, Kentaro NAKAZAWA wrote: > Hello. (sorry for my poor english ;) > Other pattern attached. > The file is very heavy at edit and undo. > Geoff Gole writes: > > If another data point will help, I've also noticed *very* slow c-mode > > fontification in a script generated header, > > /usr/include/GL/gl_mangle.h. In case you don't have this header, a > > copy is attached. > > The file is basically several thousand #defines. > // -*- mode: c++ -*- > namespace NameSpace1 { > namespace NameSpace2 { > enum { > kFooBarBazType_Attribute0000 = 0x0000, // Comment0000 > kFooBarBazType_Attribute0001 = 0x0001, // Comment0001 > kFooBarBazType_Attribute0002 = 0x0002, // Comment0002 > kFooBarBazType_Attribute0003 = 0x0003, // Comment0003 > > [....] > > kFooBarBazType_Attribute0220 = 0x00dc, // Comment0220 > kFooBarBazType_Attribute0221 = 0x00dd, // Comment0221 > kFooBarBazType_Attribute0222 = 0x00de, // Comment0222 > }; > } // namespace Namespace2 > } // namespace Namespace1 Would you try this patch and let me know how it goes, please. *** orig/cc-fonts.el 2012-01-06 12:27:14.000000000 +0000 --- cc-fonts.el 2012-01-06 21:48:54.000000000 +0000 *************** *** 1394,1399 **** --- 1394,1414 ---- (c-fontify-recorded-types-and-refs) nil) + ((and (not c-enums-contain-decls) + ;; An optimisation quickly to eliminate scans of long enum + ;; declarations in the next cond arm. + (let ((paren-state (c-parse-state))) + (and + (numberp (car paren-state)) + (save-excursion + (goto-char (car paren-state)) + (c-backward-token-2) + (or (looking-at c-brace-list-key)) + (progn + (c-backward-token-2) + (looking-at c-brace-list-key)))))) + t) + (t ;; Are we at a declarator? Try to go back to the declaration ;; to check this. If we get there, check whether a "typedef" *** orig/cc-langs.el 2012-01-06 12:27:14.000000000 +0000 --- cc-langs.el 2012-01-06 12:54:00.000000000 +0000 *************** *** 2930,2935 **** --- 2930,2941 ---- ; generics is not yet coded in CC Mode. (c-lang-defvar c-recognize-<>-arglists (c-lang-const c-recognize-<>-arglists)) + (c-lang-defconst c-enums-contain-decls + "Non-nil means that an enum structure can contain declarations." + t nil + java t) + (c-lang-defvar c-enums-contain-decls (c-lang-const c-enums-contain-decls)) + (c-lang-defconst c-recognize-paren-inits "Non-nil means that parenthesis style initializers exist, i.e. constructs like > -- > Kentaro Nakazawa -- Alan Mackenzie (Nuremberg, Germany).