[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Compiled regexp?
From: |
Bastien |
Subject: |
Compiled regexp? |
Date: |
Thu, 31 Jan 2013 14:40:05 +0100 |
User-agent: |
Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (gnu/linux) |
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
- Compiled regexp?,
Bastien <=