[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Optimizer? What optimizer?
From: |
Stefan Monnier |
Subject: |
Re: Optimizer? What optimizer? |
Date: |
Tue, 07 Jun 2011 12:01:01 -0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
>> Is there some fundamental reason defsubst does so poorly here compared
>> to defmacro?
Basically you're comparing
(if nil b (1+ b))
against
(let ((a nil) (b b)) (if a b (1+ b)))
The byte-compiler performs approximately zero analysis to try and figure
out what is the value of a variable at a given moment (i.e. none of
"constant propagation", "variable propagation", "data flow analysis",
"abstract interpretation"). So it doesn't realize that `a' has value
nil when passed to `if'.
The "optimizer" is very naive (even tho we have two optimization
phases: one working on the Elisp code after macro-expansion and another
working on the byte-code), indeed.
Stefan