From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: ntemacs hangs when openning the attached file Date: Fri, 23 May 2008 17:36:34 -0400 Message-ID: References: <42b562540805062101s3e79eecel5ddc5b19821deda2@mail.gmail.com> <20080523210123.GB4046@muc.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1211578670 28914 80.91.229.12 (23 May 2008 21:37:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 23 May 2008 21:37:50 +0000 (UTC) Cc: Eli Zaretskii , yu jie , emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri May 23 23:38:27 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JzexG-0003Zm-2s for ged-emacs-devel@m.gmane.org; Fri, 23 May 2008 23:37:38 +0200 Original-Received: from localhost ([127.0.0.1]:60570 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JzewV-0005pz-I7 for ged-emacs-devel@m.gmane.org; Fri, 23 May 2008 17:36:51 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JzewR-0005pu-HG for emacs-devel@gnu.org; Fri, 23 May 2008 17:36:47 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JzewR-0005pi-1M for emacs-devel@gnu.org; Fri, 23 May 2008 17:36:47 -0400 Original-Received: from [199.232.76.173] (port=56815 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JzewQ-0005pb-VK for emacs-devel@gnu.org; Fri, 23 May 2008 17:36:46 -0400 Original-Received: from mercure.iro.umontreal.ca ([132.204.24.67]:45256) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JzewN-0005WT-9s; Fri, 23 May 2008 17:36:43 -0400 Original-Received: from hidalgo.iro.umontreal.ca (hidalgo.iro.umontreal.ca [132.204.27.50]) by mercure.iro.umontreal.ca (Postfix) with ESMTP id 910292CFBB9; Fri, 23 May 2008 17:36:42 -0400 (EDT) Original-Received: from faina.iro.umontreal.ca (faina.iro.umontreal.ca [132.204.26.177]) by hidalgo.iro.umontreal.ca (Postfix) with ESMTP id 7B4E93FE0; Fri, 23 May 2008 17:36:34 -0400 (EDT) Original-Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id 5845A41BEC; Fri, 23 May 2008 17:36:34 -0400 (EDT) In-Reply-To: <20080523210123.GB4046@muc.de> (Alan Mackenzie's message of "Fri, 23 May 2008 21:01:23 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-DIRO-MailScanner-Information: Please contact the ISP for more information X-DIRO-MailScanner: Found to be clean X-DIRO-MailScanner-SpamCheck: n'est pas un polluriel, SpamAssassin (score=-2.82, requis 5, autolearn=not spam, ALL_TRUSTED -2.82) X-DIRO-MailScanner-From: monnier@iro.umontreal.ca X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:97618 Archived-At: >> > The current CVS header version hangs when openning the attached file. >> No, it doesn't hang, it just takes a lot of time to visit this file. >> I measured 61 seconds on a 3GHz machine. This file has 86406 lines, >> and uses some pretty non-standard formatting, such as this one: > The problem was that c-neutralize-syntax-in-CPP was inefficiently coded. > I've optimised it using essentially only Emacs primitives in the defun's > main loop. It now runs almost 2 orders of magnitude faster. Sounds good. > Eli, I'd appreciate it very much indeed if you could review this new > code, please - earlier versions of it were peculiarly troublesome. Don't know about Eli. But here's some comments: > + ;; Note: SPEED _MATTERS_ IN THIS FUNCTION!!! > + ;; > ;; This function might do invisible changes. ^^ make > + (setq pps-position beg pps-state nil) It would be a lot more lispy to explicitly let-bind pps-position and pps-state here, rather than declare them earlier without initializing them and then initializing them here. > (while (and (< (point) end) > (search-forward-regexp c-anchored-cpp-prefix end t)) > ;; If we've found a "#" inside a string/comment, ignore it. > ! (setq pps-state > ! (parse-partial-sexp pps-position (point) nil nil pps-state) > ! pps-position (point)) > ! (unless (or (nth 3 pps-state) ; in a string? > ! (nth 4 pps-state)) ; in a comment? > (setq mbeg+1 (point)) > (c-end-of-macro) ; Do we need to go forward 1 char here? No! > ! (c-neutralize-CPP-line mbeg+1 (point)) > ! (setq pps-state > ! (parse-partial-sexp pps-position (point) nil nil pps-state) > ! pps-position (point)))))) I have the impression that this second call to parse-partial-sexp is unnecessary. Stefan