Function: byte-optimize-body

byte-optimize-body is a byte-compiled function defined in byte-opt.el.gz.

Signature

(byte-optimize-body FORMS ALL-FOR-EFFECT)

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/byte-opt.el.gz
(defun byte-optimize-body (forms all-for-effect)
  ;; Optimize the cdr of a progn or implicit progn; all forms is a list of
  ;; forms, all but the last of which are optimized with the assumption that
  ;; they are being called for effect.  the last is for-effect as well if
  ;; all-for-effect is true.  returns a new list of forms.
  (let ((rest forms)
	(result nil)
	fe new)
    (while rest
      (setq fe (or all-for-effect (cdr rest)))
      (setq new (and (car rest) (byte-optimize-form (car rest) fe)))
      (when (and (consp new) (eq (car new) 'progn))
        ;; Flatten `progn' form into the body.
        (setq result (append (reverse (cdr new)) result))
        (setq new (pop result)))
      (when (or new (not fe))
	(setq result (cons new result)))
      (setq rest (cdr rest)))
    (nreverse result)))