From xemacs-m  Sun Apr 13 01:29:30 1997
Received: from mailbox2.ucsd.edu (mailbox2.ucsd.edu [132.239.1.54])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id BAA29482
	for <xemacs-beta@xemacs.org>; Sun, 13 Apr 1997 01:29:29 -0500 (CDT)
Received: from sdnp5.ucsd.edu (sdnp5.ucsd.edu [132.239.79.10]) by mailbox2.ucsd.edu (8.8.5/8.6.9) with SMTP id XAA15638 for <xemacs-beta@xemacs.org>; Sat, 12 Apr 1997 23:29:29 -0700 (PDT)
Received: by sdnp5.ucsd.edu (SMI-8.6/SMI-SVR4)
	id XAA17820; Sat, 12 Apr 1997 23:30:59 -0700
Sender: dmoore@sdnp5.ucsd.edu
To: xemacs-beta@xemacs.org
Subject: c-mode font-lock performance patch
X-Face: "oX;zS#-JU$-,WKSzG.1gGE]x^cIg!hW.dq>.f6pzS^A+(k!T|M:}5{_%>Io<>L&{hO7W4cicOQ|>/lZ1G(m%7iaCf,6Qgk0%%Bz7b2-W3jd0m_UG\Y;?]}4s0O-U)uox>P3JN)9cm]O\@,vy2e{`3pb!"pqmRy3peB90*2L
Mail-Copies-To: never
Mime-Version: 1.0 (generated by tm-edit 7.106)
Content-Type: multipart/mixed;
 boundary="Multipart_Sat_Apr_12_23:30:58_1997-1"
Content-Transfer-Encoding: 7bit
From: David Moore <dmoore@ucsd.edu>
Date: 12 Apr 1997 23:30:58 -0700
Message-ID: <rv3esvl9i5.fsf@sdnp5.ucsd.edu>
Lines: 73
X-Mailer: Gnus v5.4.43/XEmacs 20.1(beta14)

--Multipart_Sat_Apr_12_23:30:58_1997-1
Content-Type: text/plain; charset=US-ASCII


Some regexp tweaking to get ~12% speedup on c mode font lock.  About 45% 
of total font-lock time was spent in regexp, now quite a fair bit less.
The regexps should match exactly the same as before.  To be honest, I
can't see how anyone can edit code w/ the default font-lock colors. :)


--Multipart_Sat_Apr_12_23:30:58_1997-1
Content-Type: application/octet-stream; type=patch
Content-Disposition: attachment; filename="font-lock.diff"
Content-Transfer-Encoding: 7bit

--- ChangeLog.orig	Sat Apr 12 23:21:42 1997
+++ ChangeLog	Sat Apr 12 23:21:45 1997
@@ -1,3 +1,8 @@
+Sat Apr 12 23:20:31 1997  David Moore  <dmoore@ucsd.edu>
+
+	* packages/font-lock.el (c-font-lock-keywords-1): Performance
+	tuned regexps.
+
 Thu Apr 10 13:23:14 1997  Steven L Baur  <steve@altair.xemacs.org>
 
 	* prim/about.el (about-xemacs-xref): Forgot to link David Moore's
--- packages/font-lock.el.orig	Sat Apr 12 23:25:04 1997
+++ packages/font-lock.el	Sat Apr 12 23:25:09 1997
@@ -1828,7 +1828,8 @@
    
    ;; In FSF this has the simpler definition of "\\sw+" for ctoken.
    ;; I'm not sure if ours is more correct.
-   (list (concat "^\\(" ctoken "\\)[ \t]*(") 1 'font-lock-function-name-face)
+   ;; This is a subset of the next rule, and is slower when present. --dmoore
+   ;; (list (concat "^\\(" ctoken "\\)[ \t]*(") 1 'font-lock-function-name-face)
    ;;
    ;; fontify the names of functions being defined.
    ;; FSF doesn't have this but I think it should be fast for us because
@@ -1837,13 +1838,17 @@
    ;; the time to do the regexp phase of font-lock for a C file!) Not
    ;; including this discriminates against those who don't follow the
    ;; GNU coding style. --ben
+   ;; x?x?x?y?z should always be: (x(xx?)?)?y?z --dmoore
    (list (concat
-          "^\\(" ctoken "[ \t]+\\)?"	; type specs; there can be no
-          "\\(" ctoken "[ \t]+\\)?"	; more than 3 tokens, right?
-          "\\(" ctoken "[ \t]+\\)?"
+	  "^\\("
+          "\\(" ctoken "[ \t]+\\)"	; type specs; there can be no
+	  "\\("
+          "\\(" ctoken "[ \t]+\\)"	; more than 3 tokens, right?
+          "\\(" ctoken "[ \t]+\\)"
+	  "?\\)?\\)?"
           "\\([*&]+[ \t]*\\)?"		; pointer
           "\\(" ctoken "\\)[ \t]*(")	; name
-         8 'font-lock-function-name-face)
+         10 'font-lock-function-name-face)
    ;;
    ;; This is faster but not by much.  I don't see why not.
    ;(list (concat "^\\(" ctoken "\\)[ \t]*(") 1 'font-lock-function-name-face)
@@ -1942,7 +1947,9 @@
   (append
    ;;
    ;; The list `c-font-lock-keywords-1' less that for function names.
-   (cdr c-font-lock-keywords-1)
+   ;; the simple function form regexp has been removed. --dmoore
+   ;;(cdr c-font-lock-keywords-1)
+   c-font-lock-keywords-1
    ;;
    ;; Fontify function name definitions, possibly incorporating class name.
    (list

--Multipart_Sat_Apr_12_23:30:58_1997-1--

