At the moment, defcustom forms are compiled with the value expression
uncompiled, which, given how much slower uncompiled code is in XEmacs, is a
loss for us if complex expressions are given, which is routine. This byte
compiles those expressions. It also byte compiles any #'-quoted or unquoted
lambdas in the arguments, which is something GNU does (but they don’t *do*
the former right now, though they are discussing it). Their bytecomp.el has,
beyond this, lots of functionality that it should be worth merging--nothing
huge, but helpful all the same.
lisp/ChangeLog addition:
2007-11-15 Aidan Kehoe <kehoea(a)parhasard.net>
* bytecomp.el (byte-compile-file-form-custom-declare-variable):
Byte compile the DEFAULT argument to custom-declare-variable, to
speed up complex expressions; also byte compile any lambda
expressions in the argument list.
XEmacs Trunk source patch:
Diff command: cvs -q diff -Nu
Files affected: lisp/bytecomp.el
===================================================================
RCS
Index: lisp/bytecomp.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lisp/bytecomp.el,v
retrieving revision 1.20
diff -u -u -r1.20 bytecomp.el
--- lisp/bytecomp.el 2007/05/12 10:17:01 1.20
+++ lisp/bytecomp.el 2007/11/15 21:24:51
@@ -2376,13 +2376,33 @@
(put 'custom-declare-variable 'byte-hunk-handler
'byte-compile-file-form-custom-declare-variable)
(defun byte-compile-file-form-custom-declare-variable (form)
- (if (memq 'free-vars byte-compile-warnings)
- (setq byte-compile-bound-variables
- (cons (cons (nth 1 (nth 1 form))
- byte-compile-global-bit)
- byte-compile-bound-variables)))
- form)
-
+ ;; XEmacs change; our implementation byte compiles the default value code,
+ ;; which GNU's doesn't.
+ (let* ((quoted-default (car-safe (cdr-safe (cdr-safe form))))
+ (to-examine (car-safe (cdr-safe quoted-default))))
+ (if (memq 'free-vars byte-compile-warnings)
+ (setq byte-compile-bound-variables
+ (cons (cons (nth 1 (nth 1 form))
+ byte-compile-global-bit)
+ byte-compile-bound-variables)))
+ ;; Byte compile the default value, as we do for defvar.
+ (when (consp to-examine)
+ (setq form (copy-sequence form))
+ (setcdr (third form)
+ (list (byte-compile-top-level to-examine nil 'file))))
+ ;; Byte compile anything that smells like a lambda. I initially
+ ;; considered limiting it to the :initialize, :set and :get args, but
+ ;; that's not amazingly forward-compatible, and anyone expecting other
+ ;; things to be stored as data, not code, is unrealistic.
+ (loop
+ for entry in-ref (nthcdr 4 form)
+ do (cond ((and (eq 'function (car-safe entry))
+ (consp (car-safe (cdr-safe entry))))
+ (setf entry (copy-sequence entry))
+ (setcar (cdr entry) (byte-compile-lambda (car (cdr entry)))))
+ ((and (eq 'lambda (car-safe entry)))
+ (setf entry (byte-compile-lambda entry)))))
+ form))
;;;###autoload
(defun byte-compile (form)
--
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)
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-patches