aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 @@
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)