(if (and (cdr form) (null backwards))
(byte-compile-log
" all subforms of %s called for effect; deleted" form))
- (and backwards
- ;; Now optimize the rest of the forms. We need the return
- ;; values. We already did the car.
- (setcdr backwards
- (mapcar 'byte-optimize-form (cdr backwards)))
- (cons fn (nreverse backwards))))
+ (when backwards
+ ;; Now optimize the rest of the forms. We need the return
+ ;; values. We already did the car.
+ (setcdr backwards
+ (mapcar 'byte-optimize-form (cdr backwards))))
+ (cons fn (nreverse backwards)))
(cons fn (mapcar 'byte-optimize-form (cdr form)))))
((eq fn 'interactive)
;;; is not a marker or if it appears in other arithmetic).
;;; But this degree of paranoia is normally unjustified, so optimize unless
-;;; the user has done (declaim (safety 3)). Implemented in bytecomp.el.
+;;; the user has done (declaim (optimize (safety 3))). See bytecomp.el.
(defun byte-optimize-plus (form)
(byte-optimize-predicate (byte-optimize-delay-constants-math form 1 '+)))
(decf (nth 1 form) last)
(butlast form))
- ;; (- 0 x ...) --> (- (- x) ...)
- ((and (eq 0 (nth 1 form)) (>= (length form) 3))
- `(- (- ,(nth 2 form)) ,@(nthcdr 3 form)))
+ ;; (- 0 ...) -->
+ ((eq 0 (nth 1 form))
+ (case (length form)
+ ;; (- 0) --> 0
+ (2 0)
+ ;; (- 0 x) --> (- x)
+ (3 `(- ,(nth 2 form)))
+ ;; (- 0 x y ...) --> (- (- x) y ...)
+ (t `(- (- ,(nth 2 form)) ,@(nthcdr 3 form)))))
(t (byte-optimize-predicate form)))))
(put 'max 'byte-optimizer 'byte-optimize-associative-math)
(put 'min 'byte-optimizer 'byte-optimize-associative-math)
-(put '= 'byte-optimizer 'byte-optimize-binary-predicate)
(put 'eq 'byte-optimizer 'byte-optimize-binary-predicate)
(put 'eql 'byte-optimizer 'byte-optimize-binary-predicate)
(put 'equal 'byte-optimizer 'byte-optimize-binary-predicate)
(put 'string= 'byte-optimizer 'byte-optimize-binary-predicate)
(put 'string-equal 'byte-optimizer 'byte-optimize-binary-predicate)
+(put '= 'byte-optimizer 'byte-optimize-predicate)
(put '< 'byte-optimizer 'byte-optimize-predicate)
(put '> 'byte-optimizer 'byte-optimize-predicate)
(put '<= 'byte-optimizer 'byte-optimize-predicate)