On Sep 1, 2007, at 13:01, Adam Spiers wrote:
Ah, I was assuming that the elisp interpreter was intelligent enough
that if you did a concat of two or more constants, it would only build
the regexp the first time, similar to m//o in Perl.  Is that not the
case?  Or maybe it only performs this optimisation if you
byte-compile?  I found this in the elisp manual:

 -- Special Form: eval-when-compile body...
     This form marks BODY to be evaluated at compile time but not when
     the compiled program is loaded.  The result of evaluation by the
     compiler becomes a constant which appears in the compiled program.
     If you load the source file, rather than compiling it, BODY is
     evaluated normally.

     If you have a constant that needs some calculation to produce,
     `eval-when-compile' can do that at compile-time.  For example,

          (defvar my-regexp
            (eval-when-compile (regexp-opt '("aaa" "aba" "abb"))))

Maybe I should practice what I preach and use mercurial to start an
experimental branch to look at the impact on performance of doing this
refactoring :-)

I made some tests a while ago, and the impact was very small.

- Carsten



_______________________________________________
Emacs-orgmode mailing list
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

Reply via email to