comparison lisp/emacs-lisp/byte-opt.el @ 49041:55904f644d2a

(byte-optimize-nth) (byte-optimize-nthcdr): Fix for case of wrong-length forms.
author Dave Love <fx@gnu.org>
date Sun, 05 Jan 2003 00:28:18 +0000
parents ffa5e816fcad
children 0d8b17d428b5
comparison
equal deleted inserted replaced
49040:37e7677ca4d7 49041:55904f644d2a
1095 (list 'let* (reverse (cdr binds)) (nth 1 (car binds)) nil))))) 1095 (list 'let* (reverse (cdr binds)) (nth 1 (car binds)) nil)))))
1096 1096
1097 1097
1098 (put 'nth 'byte-optimizer 'byte-optimize-nth) 1098 (put 'nth 'byte-optimizer 'byte-optimize-nth)
1099 (defun byte-optimize-nth (form) 1099 (defun byte-optimize-nth (form)
1100 (if (and (= (safe-length form) 3) (memq (nth 1 form) '(0 1))) 1100 (if (= (safe-length form) 3)
1101 (list 'car (if (zerop (nth 1 form)) 1101 (if (memq (nth 1 form) '(0 1))
1102 (nth 2 form) 1102 (list 'car (if (zerop (nth 1 form))
1103 (list 'cdr (nth 2 form)))) 1103 (nth 2 form)
1104 (byte-optimize-predicate form))) 1104 (list 'cdr (nth 2 form))))
1105 (byte-optimize-predicate form))
1106 form))
1105 1107
1106 (put 'nthcdr 'byte-optimizer 'byte-optimize-nthcdr) 1108 (put 'nthcdr 'byte-optimizer 'byte-optimize-nthcdr)
1107 (defun byte-optimize-nthcdr (form) 1109 (defun byte-optimize-nthcdr (form)
1108 (if (and (= (safe-length form) 3) (not (memq (nth 1 form) '(0 1 2)))) 1110 (if (= (safe-length form) 3)
1109 (byte-optimize-predicate form) 1111 (if (memq (nth 1 form) '(0 1 2))
1110 (let ((count (nth 1 form))) 1112 (let ((count (nth 1 form)))
1111 (setq form (nth 2 form)) 1113 (setq form (nth 2 form))
1112 (while (>= (setq count (1- count)) 0) 1114 (while (>= (setq count (1- count)) 0)
1113 (setq form (list 'cdr form))) 1115 (setq form (list 'cdr form)))
1114 form))) 1116 form)
1117 (byte-optimize-predicate form))
1118 form))
1115 1119
1116 (put 'concat 'byte-optimizer 'byte-optimize-concat) 1120 (put 'concat 'byte-optimizer 'byte-optimize-concat)
1117 (defun byte-optimize-concat (form) 1121 (defun byte-optimize-concat (form)
1118 (let ((args (cdr form)) 1122 (let ((args (cdr form))
1119 (constant t)) 1123 (constant t))