From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Lennart Borgman" Newsgroups: gmane.emacs.devel Subject: Re: What is the difference between looking-at and an anchored search? Date: Thu, 17 Jul 2008 14:21:13 +0200 Message-ID: References: <487F2985.9080103@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_31577_25629977.1216297273611" X-Trace: ger.gmane.org 1216297311 4725 80.91.229.12 (17 Jul 2008 12:21:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 17 Jul 2008 12:21:51 +0000 (UTC) Cc: Emacs Devel To: "Miles Bader" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jul 17 14:22:36 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KJSV5-00035D-PU for ged-emacs-devel@m.gmane.org; Thu, 17 Jul 2008 14:22:24 +0200 Original-Received: from localhost ([127.0.0.1]:42223 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KJSUD-00065X-81 for ged-emacs-devel@m.gmane.org; Thu, 17 Jul 2008 08:21:29 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KJSU4-000612-1n for emacs-devel@gnu.org; Thu, 17 Jul 2008 08:21:20 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KJSU1-0005xl-SS for emacs-devel@gnu.org; Thu, 17 Jul 2008 08:21:18 -0400 Original-Received: from [199.232.76.173] (port=33392 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KJSU0-0005xf-16 for emacs-devel@gnu.org; Thu, 17 Jul 2008 08:21:16 -0400 Original-Received: from fg-out-1718.google.com ([72.14.220.156]:63231) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KJSTy-0005pq-Vw for emacs-devel@gnu.org; Thu, 17 Jul 2008 08:21:15 -0400 Original-Received: by fg-out-1718.google.com with SMTP id l26so2790038fgb.30 for ; Thu, 17 Jul 2008 05:21:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type:references; bh=LhdIe6dkrxCGwFuBW40DvU8gijeI5tMOW5OGfCTc9MQ=; b=ub2IgvYBVSVKX2hT2XgOYPJtmH1pSSGIqDVwzVYcnJt9Pzog9jStMDK4wsKnHR9HIm yCs2bWyMUpyjwYjXN0g2YKJ6SiY97o7VYzT9psP7/UQuLWW11ECDqsbTcef1PVo3edbj rbm2hAkjN8bFIA8yizscd77e8MrhjsV0k061M= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:references; b=dZQlnooJLdCW7PPAfipMyUv2XV2/OTCqEQwgeKX0oR7dDMiehryHkUaYEgphWZbaNd Z8zbRD+gwoBO/pInFGcwWPFIuxjd4cgTERhixG4Z0cOVQcnZ3SQkjGLz8jkgawwQP4WK Xq/Kjw2soP4eDA70Hz/It6URglUTIHKwSqjiI= Original-Received: by 10.86.29.19 with SMTP id c19mr3906015fgc.28.1216297273616; Thu, 17 Jul 2008 05:21:13 -0700 (PDT) Original-Received: by 10.86.66.2 with HTTP; Thu, 17 Jul 2008 05:21:13 -0700 (PDT) In-Reply-To: X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:100880 Archived-At: ------=_Part_31577_25629977.1216297273611 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On 7/17/08, Miles Bader wrote: > "Lennart Borgman (gmail)" writes: > > looking-at does not have a BOUND parameter, but re-search-forward > > have. This makes re-search-forward a bit more flexible. > > > > I am looking at some code where I would have use for that flexibility, > > but I wonder if there is any drawback with replacing looking-at with > > re-search-forward (with an achored pattern). > > > > Is there any? Performance? > > If you want to reject matches that extend past some point, just do > something like: > > (and (looking-at REGEXP) (<= (match-end 0) BOUND)) Thanks Miles, Yes, that is one possibility. But then perhaps I would assume that re-search-forward better might optimize that search since it can (in theory) cut off the searching at BOUND. In the case I am looking at performance is important. ------=_Part_31577_25629977.1216297273611 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline
On 7/17/08, Miles Bader <miles.bader@necel.com> wrote:
"Lennart Borgman (gmail)" <lennart.borgman@gmail.com> writes:
> looking-at does not have a BOUND parameter, but re-search-forward
> have. This makes re-search-forward a bit more flexible.
>
> I am looking at some code where I would have use for that flexibility,
> but I wonder if there is any drawback with replacing looking-at with
> re-search-forward (with an achored pattern).
>
> Is there any? Performance?

If you want to reject matches that extend past some point, just do
something like:

  (and (looking-at REGEXP) (<= (match-end 0) BOUND))
 
Thanks Miles,
 
Yes, that is one possibility. But then perhaps I would assume that re-search-forward better might optimize that search since it can (in theory) cut off the searching at BOUND. In the case I am looking at performance is important.
 
------=_Part_31577_25629977.1216297273611--