From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Helmut Eller Newsgroups: gmane.emacs.help Subject: Re: Compile regular expression Date: Mon, 21 Dec 2009 15:27:33 +0100 Message-ID: References: <87pr68bott.fsf@Traian.DecebalComp> <87hbrkbhso.fsf@Traian.DecebalComp> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1261410113 31895 80.91.229.12 (21 Dec 2009 15:41:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 21 Dec 2009 15:41:53 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Dec 21 16:41:47 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NMkOC-0000eZ-EV for geh-help-gnu-emacs@m.gmane.org; Mon, 21 Dec 2009 16:41:40 +0100 Original-Received: from localhost ([127.0.0.1]:42784 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NMkOC-0002pc-6L for geh-help-gnu-emacs@m.gmane.org; Mon, 21 Dec 2009 10:41:40 -0500 Original-Path: news.stanford.edu!usenet.stanford.edu!postnews.google.com!news1.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.kpnqwest.it!news.kpnqwest.it.POSTED!not-for-mail Original-NNTP-Posting-Date: Mon, 21 Dec 2009 08:27:34 -0600 Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) Cancel-Lock: sha1:9hN0N865JsBeqWsiSvuDajSr+iM= Original-Lines: 25 X-Usenet-Provider: http://www.giganews.com Original-NNTP-Posting-Host: 212.46.188.110 Original-X-Trace: sv3-wR2tQfOjEsVgYqB9LSVGDM17fIHCZ+ggt3HehCex3zoEGxdNsz+/gUqHuPDdS1AirKUgsilD5hAkPHF!SbrB+hADgNKYWWAgGfKfBym1TzJoZ49EugnQlPdPq78hXmBcR/WHxwYY4vFofSo= X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 Original-Xref: news.stanford.edu gnu.emacs.help:175701 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:70780 Archived-At: * 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