all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Bastien <bzg@gnu.org>
To: emacs-devel@gnu.org
Cc: Christopher Schmidt <christopher@ch.ristopher.com>,
	Carsten Dominik <dominik@science.uva.nl>
Subject: Compiled regexp?
Date: Thu, 31 Jan 2013 14:40:05 +0100	[thread overview]
Message-ID: <87lib9ii8a.fsf@bzg.ath.cx> (raw)

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.

Christopher pointed to compiled_pattern in the C part of Emacs,
suggesting that there would be no difference between the two
in terms of performance.

Can anyone confirm this is the case?

Thanks,

-- 
 Bastien




             reply	other threads:[~2013-01-31 13:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-31 13:40 Bastien [this message]
2013-01-31 14:08 ` Compiled regexp? Christopher Schmidt
2013-01-31 14:11   ` Bastien
2013-01-31 14:26 ` Andreas Schwab
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=87lib9ii8a.fsf@bzg.ath.cx \
    --to=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.