emacs-devel
[Top][All Lists]
Advanced

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

Re: Compiled regexp?


From: Dominik, Carsten
Subject: Re: Compiled regexp?
Date: Thu, 31 Jan 2013 14:42:44 +0000

On 31 jan. 2013, at 15:26, Andreas Schwab <address@hidden>
 wrote:

> Bastien <address@hidden> 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.

Hi Andreas, thanks for the reply.  Just to double-check, I rephrase the 
question:  

Caching of compiled regular expression keys in on string contents, not on a 
particular string object (so the cache looks for an earlier compiled string 
with (something like0 `equal' not with `eq').  Is this correct?  Because the 
difference between the two procedures shown above is that in the first case, 
the same lisp object enters the re-search-forward, while in the second case it 
is a different string of equal content each time.

Thank you.

- Carsten


reply via email to

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