From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Stefan Monnier" Newsgroups: gmane.emacs.cc-mode.general,gmane.emacs.devel Subject: Re: Advising in cc-awk.el and namespace Date: Fri, 11 Jul 2003 13:35:36 -0400 Sender: cc-mode-help-admin@lists.sourceforge.net Message-ID: <200307111735.h6BHZaZO023544@rum.cs.yale.edu> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: main.gmane.org 1057945003 16472 80.91.224.249 (11 Jul 2003 17:36:43 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 11 Jul 2003 17:36:43 +0000 (UTC) Cc: Alan Mackenzie , monnier+gnu/emacs/pretest@cs.yale.edu, bug-cc-mode@gnu.org, emacs-devel@gnu.org Original-X-From: cc-mode-help-admin@lists.sourceforge.net Fri Jul 11 19:36:40 2003 Return-path: Original-Received: from lists.sourceforge.net ([66.35.250.206] helo=sc8-sf-list2.sourceforge.net) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19b1p2-0004HQ-00 for ; Fri, 11 Jul 2003 19:36:40 +0200 Original-Received: from sc8-sf-list1-b.sourceforge.net ([10.3.1.13] helo=sc8-sf-list1.sourceforge.net) by sc8-sf-list2.sourceforge.net with esmtp (Exim 3.31-VA-mm2 #1 (Debian)) id 19b1pw-000082-00; Fri, 11 Jul 2003 10:37:36 -0700 Original-Received: from fencepost.gnu.org ([199.232.76.164]) by sc8-sf-list1.sourceforge.net with esmtp (Cipher TLSv1:DES-CBC3-SHA:168) (Exim 3.31-VA-mm2 #1 (Debian)) id 19b1os-0007WT-00 for ; Fri, 11 Jul 2003 10:36:31 -0700 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by fencepost.gnu.org with esmtp (Exim 4.20) id 19b1oo-0005se-8q for bug-cc-mode@gnu.org; Fri, 11 Jul 2003 13:36:26 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) id 19b1of-0002Bf-GU for bug-cc-mode@gnu.org; Fri, 11 Jul 2003 13:36:18 -0400 Original-Received: from rum.cs.yale.edu ([128.36.229.169]) by monty-python.gnu.org with esmtp (Exim 4.20) id 19b1o5-0001yV-IP; Fri, 11 Jul 2003 13:35:41 -0400 Original-Received: from rum.cs.yale.edu (localhost [127.0.0.1]) by rum.cs.yale.edu (8.12.8/8.12.8) with ESMTP id h6BHZa4Z023546; Fri, 11 Jul 2003 13:35:36 -0400 Original-Received: (from monnier@localhost) by rum.cs.yale.edu (8.12.8/8.12.8/Submit) id h6BHZaZO023544; Fri, 11 Jul 2003 13:35:36 -0400 X-Mailer: exmh version 2.4 06/23/2000 with nmh-1.0.4 Original-To: Richard Stallman X-MIME-Autoconverted: from 8bit to quoted-printable by rum.cs.yale.edu id h6BHZa4Z023546 Errors-To: cc-mode-help-admin@lists.sourceforge.net X-BeenThere: cc-mode-help@lists.sourceforge.net X-Mailman-Version: 2.0.9-sf.net Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Bug reports, feature requests, and general talk about CC Mode. List-Unsubscribe: , List-Archive: X-Original-Date: Fri, 11 Jul 2003 13:35:36 -0400 Xref: main.gmane.org gmane.emacs.cc-mode.general:656 gmane.emacs.devel:15544 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:15544 > load a large file (say, ..../emacs/src/keyboard.c) wait for jit-loc= k to > finish fontifying it in the background, then make a small change ne= ar the > beginning of this file, needlessly refontifying ~320kBytes consumes= ~55% > of the CPU's power for 3=BD minutes. >=20 > Why does a small change near the beginning refontify the whole file? > I suppose there are some small changes that might legitimately do so, > but I would not expect most small changes to do so. What's up? Because in general, it might be necessary and font-lock does not try to be clever here. Basically syntactic-fontification (fontification of comments and string) depends on the output of `syntax-ppss' and because font-lock-keyword rules are order-dependent (they typically are only applied if there isn't already some fontification at point, so that keywords aren't highlighted inside strings), after redoing syntactic-fontification, keywords fontification needs to be redone as well. A change at pos N potentially changes the output of syntax-ppss for all pos>N, so jit-lock just refontifies everything (in the background with jit-lock-stealth-*). Of course, in practice the output of syntax-ppss is generally not changed for all pos>N but only for NN but the change is marginal or irrelevant and will not influence the result of font-locking), so we coul= d be more clever, but we would need to cache the parse-state-before-change so we can compare it to the parse-state-after-change so we can stop when they are equal again. It might be worth the effort, but nobody has bothered coding it up yet. Turning off jit-lock-stealth-* is a simpler workaround for the CPU-power-wasting problem. Stefan ------------------------------------------------------- This SF.Net email sponsored by: Parasoft Error proof Web apps, automate testing & more. Download & eval WebKing and get a free book. www.parasoft.com/bulletproofapps1