- (cond ((null (cdr form))
- (condition-case ()
- (eval form)
- (error form)))
-
- ;; `add1' and `sub1' are a marginally fewer instructions
- ;; than `plus' and `minus', so use them when possible.
- ((and (null (nthcdr 3 form))
- (eq (nth 2 form) 1))
- (list '1+ (nth 1 form))) ; (+ x 1) --> (1+ x)
- ((and (null (nthcdr 3 form))
- (eq (nth 1 form) 1))
- (list '1+ (nth 2 form))) ; (+ 1 x) --> (1+ x)
- ((and (null (nthcdr 3 form))
- (eq (nth 2 form) -1))
- (list '1- (nth 1 form))) ; (+ x -1) --> (1- x)
- ((and (null (nthcdr 3 form))
- (eq (nth 1 form) -1))
- (list '1- (nth 2 form))) ; (+ -1 x) --> (1- x)
-
-;;; It is not safe to delete the function entirely
-;;; (actually, it would be safe if we know the sole arg
-;;; is not a marker).
-;; ((null (cdr (cdr form))) (nth 1 form))
- (t form)))
+ (case (length (cdr form))
+ ((0)
+ (condition-case ()
+ (eval form)
+ (error form)))
+
+ ;; `add1' and `sub1' are a marginally fewer instructions
+ ;; than `plus' and `minus', so use them when possible.
+ ((2)
+ (cond
+ ((eq (nth 1 form) 1) `(1+ ,(nth 2 form))) ; (+ 1 x) --> (1+ x)
+ ((eq (nth 2 form) 1) `(1+ ,(nth 1 form))) ; (+ x 1) --> (1+ x)
+ ((eq (nth 1 form) -1) `(1- ,(nth 2 form))) ; (+ -1 x) --> (1- x)
+ ((eq (nth 2 form) -1) `(1- ,(nth 1 form))) ; (+ x -1) --> (1- x)
+ (t form)))
+
+ ;; It is not safe to delete the function entirely
+ ;; (actually, it would be safe if we know the sole arg
+ ;; is not a marker).
+ ;; ((null (cdr (cdr form))) (nth 1 form))
+ (t form)))