APPROVE COMMIT
NOTE: This patch has been committed.
# HG changeset patch
# User Aidan Kehoe <kehoea(a)parhasard.net>
# Date 1337005007 -3600
# Node ID b4715fcbe00185e5ab8c00208e14d15fb3c936a9
# Parent daf5accfe9736ac481b1bdd6063d060f8b4a633d
#'byte-optimize-letX; group constant initialisations together in let forms
lisp/ChangeLog addition:
2012-05-14 Aidan Kehoe <kehoea(a)parhasard.net>
* byte-optimize.el (byte-optimize-letX):
In (let ...) forms, group constant initialisations together, so we
can just dup in the byte code.
diff -r daf5accfe973 -r b4715fcbe001 lisp/ChangeLog
--- a/lisp/ChangeLog Mon May 14 08:46:05 2012 +0100
+++ b/lisp/ChangeLog Mon May 14 15:16:47 2012 +0100
@@ -1,3 +1,9 @@
+2012-05-14 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * byte-optimize.el (byte-optimize-letX):
+ In (let ...) forms, group constant initialisations together, so we
+ can just dup in the byte code.
+
2012-05-14 Aidan Kehoe <kehoea(a)parhasard.net>
Update minibuf.el to use #'test-completion, use the generality of
diff -r daf5accfe973 -r b4715fcbe001 lisp/byte-optimize.el
--- a/lisp/byte-optimize.el Mon May 14 08:46:05 2012 +0100
+++ b/lisp/byte-optimize.el Mon May 14 15:16:47 2012 +0100
@@ -1194,7 +1194,27 @@
;; No bindings
(cons 'progn (cdr (cdr form))))
((or (nth 2 form) (nthcdr 3 form))
- form)
+ (if (and (eq 'let (car form)) (> (length (nth 1 form)) 2))
+ ;; Group constant initialisations together, so we can
+ ;; just dup in the lap code. Can't group other
+ ;; initialisations together if they have side-effects,
+ ;; that would re-order them.
+ (let ((sort (stable-sort
+ (copy-list (nth 1 form))
+ #'< :key #'(lambda (object)
+ (cond ((atom object)
+ most-positive-fixnum)
+ ((null (cadr object))
+ most-positive-fixnum)
+ ((byte-compile-trueconstp
+ (cadr object))
+ (mod (sxhash (cadr object))
+ most-positive-fixnum))
+ (t 0))))))
+ (if (equal sort (nth 1 form))
+ form
+ `(let ,sort ,@(cddr form))))
+ form))
;; The body is nil
((eq (car form) 'let)
(append '(progn) (mapcar 'car-safe (mapcar 'cdr-safe (nth 1 form)))
--
‘Liston operated so fast that he once accidentally amputated an assistant’s
fingers along with a patient’s leg, […] The patient and the assistant both
died of sepsis, and a spectator reportedly died of shock, resulting in the
only known procedure with a 300% mortality.’ (Atul Gawande, NEJM, 2012)
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-patches