[PATCH] Add a correct version of the (featurep 'xemacs) optimisation

Aidan Kehoe kehoea at parhasard.net
Mon Oct 1 11:29:36 EDT 2007


Despite that this optimisation can’t really be added to distinguish between
SXEmacs and XEmacs, I still think it’s worthwhile. Here is X for the top
fifteen most frequent calls to (featurep 'X) in the packages tree:

250 xemacs
58 mule
42 xpm
32 menubar
27 toolbar
19 custom
15 infodock
12 sparcworks
10 ediff-init
10 itimer
10 skk-cursor
10 x
8 ange-ftp
8 font-lock

There are in total 860 such calls (that is, simple (featreup 'X) calls), so
eliminating (featurep 'xemacs) is disproportionately helpful. The other
features in my patch, not so much, but they do provide a framework should we
ever take the time to work out which features have always been available
ever since the last time our bytecode became incompatible.

2007-10-01  Aidan Kehoe  <kehoea at parhasard.net>

	* byte-optimize.el:
	* byte-optimize.el (byte-optimize-ever-present-features): New.
	* byte-optimize.el (byte-optimize-featurep): New.
	Optimise calls to (featurep 'xemacs) to t, since our byte code
	refuses to run on GNU Emacs. Also optimises away checks for cl,
	cl-extra, cl-19 and backquote, a conservative list of those
	features that have been available in every XEmacs build since the
	last time our opcodes changed. 

XEmacs Trunk source patch:
Diff command:   cvs -q diff -u
Files affected: lisp/byte-optimize.el
===================================================================
RCS

Index: lisp/byte-optimize.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lisp/byte-optimize.el,v
retrieving revision 1.12
diff -u -r1.12 byte-optimize.el
--- lisp/byte-optimize.el	2007/09/15 19:11:55	1.12
+++ lisp/byte-optimize.el	2007/10/01 15:21:25
@@ -1169,6 +1169,21 @@
 	(eval form)
       form)))
 
+(defvar byte-optimize-ever-present-features 
+  '(xemacs cl cl-extra cl-19 backquote))
+
+(put 'featurep 'byte-optimizer 'byte-optimize-featurep)
+(defun byte-optimize-featurep (form)
+  (let ((to-check (cdr-safe form)))
+    (if (memq (car-safe
+	       (cdr-safe
+		(car-safe
+		 (cdr-safe 
+		  form))))
+	      byte-optimize-ever-present-features)
+	t
+      form)))
+
 
 ;;; enumerating those functions which need not be called if the returned
 ;;; value is not used.  That is, something like

-- 
On the quay of the little Black Sea port, where the rescued pair came once
more into contact with civilization, Dobrinton was bitten by a dog which was
assumed to be mad, though it may only have been indiscriminating. (Saki)



More information about the XEmacs-Patches mailing list