[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: byte-opt.el addition - optimize list of compile-time constants
From: |
Stefan Monnier |
Subject: |
Re: byte-opt.el addition - optimize list of compile-time constants |
Date: |
Wed, 08 Dec 2004 11:56:49 -0500 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux) |
> I dug through the byte-compiler a bit and determined that it makes no
> attempt whatsoever to optimize (list ...) expressions. So I wrote a
The reason for this is that (eq (list 1) (list 1)) returns nil.
So the optimization which replaces (list 1) with '(1) can change the
behavior of the code.
Example:
(defun foo () (list 1))
...
(message "%s" (if (eq (foo) (foo)) "Optimized" "No optimization"))
Admittedly, such situations are relatively uncommon, but they do arise and
it is very difficult [read: impossible] to detect them,
Stefan
PS: Note that `concat' has the same problem, and yet (concat "foo" "bar")
is byte-optimized to "foobar". The reason for the difference is that
it so happens that such differences matter much less often for strings,
and also that the optimzation has been used for such a long time that it
can be considered as part of the semantics of `concat'.
- byte-opt.el addition - optimize list of compile-time constants, Zack Weinberg, 2004/12/08
- Re: byte-opt.el addition - optimize list of compile-time constants,
Stefan Monnier <=
- Re: byte-opt.el addition - optimize list of compile-time constants, Zack Weinberg, 2004/12/08
- Re: byte-opt.el addition - optimize list of compile-time constants, Stefan Monnier, 2004/12/08
- Re: byte-opt.el addition - optimize list of compile-time constants, Zack Weinberg, 2004/12/08
- Re: byte-opt.el addition - optimize list of compile-time constants, Stefan Monnier, 2004/12/08
- Re: byte-opt.el addition - optimize list of compile-time constants, Zack Weinberg, 2004/12/08