# HG changeset patch # User Dave Love # Date 1041726498 0 # Node ID 55904f644d2ae40bcbf2f96714f9455e6ea731bc # Parent 37e7677ca4d7ea642be5caab7a813d6eb0e1c8c3 (byte-optimize-nth) (byte-optimize-nthcdr): Fix for case of wrong-length forms. diff -r 37e7677ca4d7 -r 55904f644d2a lisp/emacs-lisp/byte-opt.el --- a/lisp/emacs-lisp/byte-opt.el Sun Jan 05 00:18:44 2003 +0000 +++ b/lisp/emacs-lisp/byte-opt.el Sun Jan 05 00:28:18 2003 +0000 @@ -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)