emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] proposal: defconst/defcustom org-tags-regexp


From: Carsten Dominik
Subject: Re: [Orgmode] proposal: defconst/defcustom org-tags-regexp
Date: Thu, 19 Jul 2007 17:08:48 +0200


On Jul 19, 2007, at 15:08, Eddward DeVilla wrote:

On 7/18/07, Carsten Dominik <address@hidden> wrote:
Do you know a solution for this problem?

Does emacs let you manually compile a regular expression?  If so, it
might be possible to recompile REs when ever they change.

This is not the issue.  Yes, Emacs compiles regular expressions
whenever necessary.  However, consider the following loop:

   (while (re-search-forward "^aaa" nil t)
     (do-something)

In this case, Emacs will compile the regexp once and then use
it potentially many times.

However, in the following case:

   (while (re-search-forward (concat "^" some-variable) nil t)
      (do-something)

The regular expression wil be re-compiled all the time.
In this case you can work around it by doing:

   (let ((re (concat "^" some-variable)))
     (while (re-search-forward re nil t)
       (do-something...))

But if the loop is calling functions, and the regular expression
is being built and used in those functions, this might slow down
things.

Now, I am not sure how slow actually, I am basically following the
arguments in Jeffrey E. F. Friedl's excellent book
"Mastering Regular Expressions", but I am not sure how large the
effect will be in the end. I remember that in perl this was significant,
so I am assuming it is in Emacs.

I would like to factor out more regexps into variables, and may do
so with time - but this does not have priority.

- Carsten



--
Carsten Dominik
Sterrenkundig Instituut "Anton Pannekoek"
Universiteit van Amsterdam
Kruislaan 403
NL-1098SJ Amsterdam
phone: +31 20 525 7477





reply via email to

[Prev in Thread] Current Thread [Next in Thread]