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: Thu, 15 Dec 2011 13:43:32 +0000 Message-ID: <20111215134332.GA5698@acm.acm> References: <83vcpxbxn0.fsf@gnu.org> <20111203151824.GA4566@acm.acm> <87pqfso5d3.fsf@isil.kanru.info> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1323956991 5336 80.91.229.12 (15 Dec 2011 13:49:51 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 15 Dec 2011 13:49:51 +0000 (UTC) Cc: Eli Zaretskii , emacs-devel@gnu.org To: Kan-Ru Chen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Dec 15 14:49:47 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 1RbBgw-0004Fu-Qz for ged-emacs-devel@m.gmane.org; Thu, 15 Dec 2011 14:49:46 +0100 Original-Received: from localhost ([::1]:51708 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbBgw-0004NF-GZ for ged-emacs-devel@m.gmane.org; Thu, 15 Dec 2011 08:49:46 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:34119) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbBgq-0004Kv-FN for emacs-devel@gnu.org; Thu, 15 Dec 2011 08:49:44 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RbBgl-0000TH-Oi for emacs-devel@gnu.org; Thu, 15 Dec 2011 08:49:40 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:49856 helo=mail.muc.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbBgl-0000St-G7 for emacs-devel@gnu.org; Thu, 15 Dec 2011 08:49:35 -0500 Original-Received: (qmail 80404 invoked by uid 3782); 15 Dec 2011 13:49:32 -0000 Original-Received: from acm.muc.de (pD951BED6.dip.t-dialin.net [217.81.190.214]) by colin.muc.de (tmda-ofmipd) with ESMTP; Thu, 15 Dec 2011 14:49:31 +0100 Original-Received: (qmail 5817 invoked by uid 1000); 15 Dec 2011 13:43:32 -0000 Content-Disposition: inline In-Reply-To: <87pqfso5d3.fsf@isil.kanru.info> 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:146725 Archived-At: Hello mk.4 Kanru. On Tue, Dec 13, 2011 at 11:31:36PM +0800, Kan-Ru Chen wrote: > Alan Mackenzie writes: > > By a happy coincidence, I've just tracked down another sluggishness (in > > large array initialisations, reported by Peter Milliken on bug-cc-mode) > > which looks to have exactly the same cause, namely > > `c-font-lock-enclosing-decls' which fontifies the innards of a > > struct/union/enum when jit-lock etc. starts in the middle of it. > Is this the same problem? > http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10288 > I cannot find the original report by Peter. Would you please try the following patch and let me know how it goes. Thanks! *** orig/cc-engine.el 2011-12-15 09:06:28.000000000 +0000 --- cc-engine.el 2011-12-15 13:41:25.000000000 +0000 *************** *** 8073,8078 **** --- 8073,8094 ---- next-open-brace (c-pull-open-brace paren-state))) open-brace)) + (defun c-cheap-inside-bracelist-p (paren-state) + ;; Return the position of the L-brace if point is inside a brace list + ;; initialization of an array, etc. This is an approximate function, + ;; designed for speed over accuracy. We simply search for "= {" (naturally + ;; with syntactic whitespace allowed). PAREN-STATE is the normal thing that + ;; it is everywhere else. + (let (b-pos) + (save-excursion + (while + (and (setq b-pos (c-pull-open-brace paren-state)) + (progn (goto-char b-pos) + (c-backward-sws) + (c-backward-token-2) + (not (looking-at "="))))) + b-pos))) + (defun c-inside-bracelist-p (containing-sexp paren-state) ;; return the buffer position of the beginning of the brace list ;; statement if we're inside a brace list, otherwise return nil. *** orig/cc-fonts.el 2011-12-15 09:06:28.000000000 +0000 --- cc-fonts.el 2011-12-15 13:15:43.000000000 +0000 *************** *** 1394,1399 **** --- 1394,1405 ---- (c-fontify-recorded-types-and-refs) nil) + ;; If point is inside a bracelist, there's no point checking it + ;; being at a declarator. + ((let ((paren-state (c-parse-state))) + (c-cheap-inside-bracelist-p paren-state)) + nil) + (t ;; Are we at a declarator? Try to go back to the declaration ;; to check this. If we get there, check whether a "typedef" > -- > Kanru -- Alan Mackenzie (Nuremberg, Germany).