all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Compile regular expression
@ 2009-12-21 10:31 Cecil Westerhof
  2009-12-21 11:14 ` Helmut Eller
  0 siblings, 1 reply; 4+ messages in thread
From: Cecil Westerhof @ 2009-12-21 10:31 UTC (permalink / raw)
  To: help-gnu-emacs

I am working with CL at the moment. When you compile a regular
expression in CL, the program is about 4 times as fast. This program is
a translation of something I first wrote in elisp. So I was wondering if
I could get the same advantage in my elisp code. But I could find
nothing to compile a regular expression. Is this true, or am I not
looking correctly?

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Compile regular expression
  2009-12-21 10:31 Compile regular expression Cecil Westerhof
@ 2009-12-21 11:14 ` Helmut Eller
  2009-12-21 13:03   ` Cecil Westerhof
  0 siblings, 1 reply; 4+ messages in thread
From: Helmut Eller @ 2009-12-21 11:14 UTC (permalink / raw)
  To: help-gnu-emacs

* Cecil Westerhof [2009-12-21 11:31+0100] writes:

> I am working with CL at the moment. When you compile a regular
> expression in CL, the program is about 4 times as fast. This program is
> a translation of something I first wrote in elisp. So I was wondering if
> I could get the same advantage in my elisp code. But I could find
> nothing to compile a regular expression. Is this true, or am I not
> looking correctly?

Emacs uses a cache for compiled regexps internally but it's not exposed.

Helmut


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Compile regular expression
  2009-12-21 11:14 ` Helmut Eller
@ 2009-12-21 13:03   ` Cecil Westerhof
  2009-12-21 14:27     ` Helmut Eller
  0 siblings, 1 reply; 4+ messages in thread
From: Cecil Westerhof @ 2009-12-21 13:03 UTC (permalink / raw)
  To: help-gnu-emacs

Helmut Eller <eller.helmut@gmail.com> writes:

>> I am working with CL at the moment. When you compile a regular
>> expression in CL, the program is about 4 times as fast. This program is
>> a translation of something I first wrote in elisp. So I was wondering if
>> I could get the same advantage in my elisp code. But I could find
>> nothing to compile a regular expression. Is this true, or am I not
>> looking correctly?
>
> Emacs uses a cache for compiled regexps internally but it's not exposed.

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.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Compile regular expression
  2009-12-21 13:03   ` Cecil Westerhof
@ 2009-12-21 14:27     ` Helmut Eller
  0 siblings, 0 replies; 4+ messages in thread
From: Helmut Eller @ 2009-12-21 14:27 UTC (permalink / raw)
  To: help-gnu-emacs

* 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)
	break;

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

Helmut


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-12-21 14:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-21 10:31 Compile regular expression Cecil Westerhof
2009-12-21 11:14 ` Helmut Eller
2009-12-21 13:03   ` Cecil Westerhof
2009-12-21 14:27     ` Helmut Eller

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.