[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Byte compiler inefficiency
From: |
David Kastrup |
Subject: |
Byte compiler inefficiency |
Date: |
Sun, 07 Aug 2005 13:34:43 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
Hi, we have
(defsubst cadr (x)
"Return the car of the cdr of X."
(car (cdr x)))
And if we use that, for example, in
(defun woozle (blurb) (cadr blurb))
then the byte compiler delivers the result:
byte code for woozle:
args: (blurb)
0 varref blurb
1 dup
2 varbind x
3 cdr
4 car
5 unbind 1
6 return
The binding for x is completely unnecessary and wasteful. FWIW, the
XEmacs byte compiler does not do this unnecessary binding.
I think that the byte compiler should be smart enough to remove
unnecessary bindings from defsubst stuff consisting purely of
side-effect free primitives and substitutions: those are not likely to
be advised, and if they are, one can still mark them as
non-side-effect free after the advice is activated.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum