summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorDave Love <fx@gnu.org>2003-01-05 00:28:18 +0000
committerDave Love <fx@gnu.org>2003-01-05 00:28:18 +0000
commit56cfa2440ebcfe17fa70175165effc24bfa44b3d (patch)
treec33116beb84db2d164d778dd9459d39e26284da8 /lisp/emacs-lisp
parent98e99f6e6481a3eb097fc67ca7211e56e7e6452c (diff)
downloademacs-56cfa2440ebcfe17fa70175165effc24bfa44b3d.tar.gz
emacs-56cfa2440ebcfe17fa70175165effc24bfa44b3d.tar.bz2
emacs-56cfa2440ebcfe17fa70175165effc24bfa44b3d.zip
(byte-optimize-nth)
(byte-optimize-nthcdr): Fix for case of wrong-length forms.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/byte-opt.el28
1 files changed, 16 insertions, 12 deletions
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index 8a44ea020f3..7ccd2698b2c 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -1097,21 +1097,25 @@
(put 'nth 'byte-optimizer 'byte-optimize-nth)
(defun byte-optimize-nth (form)
- (if (and (= (safe-length form) 3) (memq (nth 1 form) '(0 1)))
- (list 'car (if (zerop (nth 1 form))
- (nth 2 form)
- (list 'cdr (nth 2 form))))
- (byte-optimize-predicate form)))
+ (if (= (safe-length form) 3)
+ (if (memq (nth 1 form) '(0 1))
+ (list 'car (if (zerop (nth 1 form))
+ (nth 2 form)
+ (list 'cdr (nth 2 form))))
+ (byte-optimize-predicate form))
+ form))
(put 'nthcdr 'byte-optimizer 'byte-optimize-nthcdr)
(defun byte-optimize-nthcdr (form)
- (if (and (= (safe-length form) 3) (not (memq (nth 1 form) '(0 1 2))))
- (byte-optimize-predicate form)
- (let ((count (nth 1 form)))
- (setq form (nth 2 form))
- (while (>= (setq count (1- count)) 0)
- (setq form (list 'cdr form)))
- form)))
+ (if (= (safe-length form) 3)
+ (if (memq (nth 1 form) '(0 1 2))
+ (let ((count (nth 1 form)))
+ (setq form (nth 2 form))
+ (while (>= (setq count (1- count)) 0)
+ (setq form (list 'cdr form)))
+ form)
+ (byte-optimize-predicate form))
+ form))
(put 'concat 'byte-optimizer 'byte-optimize-concat)
(defun byte-optimize-concat (form)