emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: weird desktop.el change


From: Markus Triska
Subject: Re: weird desktop.el change
Date: Fri, 13 Apr 2007 19:02:07 +0200

Miles Bader <address@hidden> writes:

> The process of substituting "mapc" for "mapcar" when the result
> isn't used is not only a hugely widespread tweak in the lisp
> community (a "no brainer" as you might call it), indeed it's an
> obvious optimization for even a very stupid lisp compiler...

Available with this patch:

2007-04-13  Markus Triska  <address@hidden>

        * emacs-lisp/byte-opt.el (byte-optimize-form-code-walker): rewrite
        `mapcar' to `mapc' when called for effect

Index: byte-opt.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/emacs-lisp/byte-opt.el,v
retrieving revision 1.94
diff -c -r1.94 byte-opt.el
*** byte-opt.el 11 Apr 2007 17:10:42 -0000      1.94
--- byte-opt.el 13 Apr 2007 16:48:08 -0000
***************
*** 408,413 ****
--- 408,418 ----
                                                 (prin1-to-string clause))
                              clause))
                         (cdr form))))
+         ((and for-effect (eq fn 'mapcar))
+          (when (/= (length form) 3)
+            (byte-compile-warn "wrong number of arguments for `mapcar'"))
+          (byte-compile-warn "`mapcar' called for effect; using `mapc'")
+          (byte-optimize-form (cons 'mapc (cdr form)) for-effect))
          ((eq fn 'progn)
           ;; as an extra added bonus, this simplifies (progn <x>) --> <x>
           (if (cdr (cdr form))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]