I don't think it should be applied in this form.
Mikio Nakajima <minakaji(a)osaka.email.ne.jp> writes:
- (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)))
These ones should certainly stay..
(nth 0 l) --> (car 0)
(nthcdr 0 l) --> l
(nthcdr 1 l) --> (cdr l)
The others you removed are.
(nth 1 l) --> (car (cdr l))
(nthcdr 2 l) --> (cdr (cdr l))
Did you do benchmarking on these ones?
I think expanding the forms allows the bytecompiler to
do a better job with things like (nthcdr 2 '(1 2))
Jan