From: Andreas Schwab <schwab@linux-m68k.org>
To: Bastien <bzg@gnu.org>
Cc: Christopher Schmidt <christopher@ch.ristopher.com>,
Carsten Dominik <dominik@science.uva.nl>,
emacs-devel@gnu.org
Subject: Re: Compiled regexp?
Date: Thu, 31 Jan 2013 15:26:24 +0100 [thread overview]
Message-ID: <mvmip6do2cv.fsf@hawking.suse.de> (raw)
In-Reply-To: <87lib9ii8a.fsf@bzg.ath.cx> (Bastien's message of "Thu, 31 Jan 2013 14:40:05 +0100")
Bastien <bzg@gnu.org> writes:
> After Christopher submitted a patch for org-mode, Carsten and him
> discussed the difference between these two patterns:
>
> ;; Concat in defconst
> (defconst my-pattern (concat "^" "xyz"))
> (re-search-forward my-pattern ...)
>
> ;; Concat in re-search-forward
> (defconst my-partial-pattern "xyz")
> (re-search-forward (concat "^" my-partial-pattern) ...)
>
> Both Carsten and I thought there was some optimization done
> by Emacs so that the first pattern is more efficient than the
> second one. (concat "^" "xyz") would be "cached", not eval'ed
> each time you search for my-pattern.
The first pattern evaluates (concat "^" "xyz") once when my-pattern is
defined. The second case evalutes (concat "^" my-partial-pattern) each
time the containing sexp is evaluated. Other than that there is no
difference wrt. re-search-forward.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
next prev parent reply other threads:[~2013-01-31 14:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-31 13:40 Compiled regexp? Bastien
2013-01-31 14:08 ` Christopher Schmidt
2013-01-31 14:11 ` Bastien
2013-01-31 14:26 ` Andreas Schwab [this message]
2013-01-31 14:42 ` Dominik, Carsten
2013-01-31 15:28 ` Stefan Monnier
2013-01-31 15:34 ` Dominik, Carsten
2013-01-31 15:55 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=mvmip6do2cv.fsf@hawking.suse.de \
--to=schwab@linux-m68k.org \
--cc=bzg@gnu.org \
--cc=christopher@ch.ristopher.com \
--cc=dominik@science.uva.nl \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.