[Top][All Lists]

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

Re: Compile regular expression

From: Helmut Eller
Subject: Re: Compile regular expression
Date: Mon, 21 Dec 2009 15:27:33 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

* Cecil Westerhof [2009-12-21 14:03+0100] writes:

> Okay, then in principle I do not have to worry. But one more question. I
> call a function a lot (five million times) with a string containing the
> regular expression. Does the cache work in this case also? Because the
> string is evaluated in the function and looses focus when returning.

That seems to be the most obvious use for a cache.
A simple way to answer such question is to read the source code.  Here
is the condition for cache lookups:

      if (SCHARS (cp->regexp) == SCHARS (pattern)
          && STRING_MULTIBYTE (cp->regexp) == STRING_MULTIBYTE (pattern)
          && !NILP (Fstring_equal (cp->regexp, pattern))
          && EQ (cp->buf.translate, (! NILP (translate) ? translate : 
make_number (0)))
          && cp->posix == posix
          && (EQ (cp->syntax_table, Qt)
              || EQ (cp->syntax_table, current_buffer->syntax_table))
          && !NILP (Fequal (cp->whitespace_regexp, Vsearch_spaces_regexp))
          && cp->buf.charset_unibyte == charset_unibyte)

As you can see, string-equal is for comparisions.


reply via email to

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