;; This implies that you cannot simply destructively modify the list;
;; you must return something not EQ to it if you make an optimization.
-(defsubst byte-opt--bool-value-form (form)
- "The form in FORM that yields its boolean value, possibly FORM itself."
- (while (let ((head (car-safe form)))
- (cond ((memq head '( progn inline save-excursion save-restriction
- save-current-buffer))
- (setq form (car (last (cdr form))))
- t)
- ((memq head '(let let*))
- (setq form (car (last (cddr form))))
- t)
- ((memq head '( prog1 unwind-protect copy-sequence identity
- reverse nreverse sort))
- (setq form (nth 1 form))
- t)
- ((memq head '(mapc setq setcar setcdr puthash set))
- (setq form (nth 2 form))
- t)
- ((memq head '(aset put function-put))
- (setq form (nth 3 form))
- t))))
- form)
-
;; If the function is being called with constant integer args,
;; evaluate as much as possible at compile-time. This optimizer
;; assumes that the function is associative, like min or max.
(error "Eager macro-expansion failure: %S" err)
form)))))
+(defsubst byte-opt--bool-value-form (form)
+ "The form in FORM that yields its boolean value, possibly FORM itself."
+ (while (let ((head (car-safe form)))
+ (cond ((memq head '( progn inline save-excursion save-restriction
+ save-current-buffer))
+ (setq form (car (last (cdr form))))
+ t)
+ ((memq head '(let let*))
+ (setq form (car (last (cddr form))))
+ t)
+ ((memq head '( prog1 unwind-protect copy-sequence identity
+ reverse nreverse sort))
+ (setq form (nth 1 form))
+ t)
+ ((memq head '(mapc setq setcar setcdr puthash set))
+ (setq form (nth 2 form))
+ t)
+ ((memq head '(aset put function-put))
+ (setq form (nth 3 form))
+ t))))
+ form)
+
(defun byte-compile-trueconstp (form)
"Return non-nil if FORM always evaluates to a non-nil value."
(setq form (byte-opt--bool-value-form form))