From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.help Subject: Re: `looking-back' strange warning Date: Fri, 02 Oct 2015 17:21:23 +0200 Message-ID: <87fv1tthxo.fsf@gnu.org> References: <560B9C7F.2060301@easy-emacs.de> <560CD7CE.4010404@yandex.ru> <560CE576.9030109@easy-emacs.de> <878u7nhueu.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1443804242 21287 80.91.229.3 (2 Oct 2015 16:44:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 2 Oct 2015 16:44:02 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Oct 02 18:43:47 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Zi3Qu-0005NS-4q for geh-help-gnu-emacs@m.gmane.org; Fri, 02 Oct 2015 18:43:44 +0200 Original-Received: from localhost ([::1]:33178 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zi3Qt-0007FY-Eq for geh-help-gnu-emacs@m.gmane.org; Fri, 02 Oct 2015 12:43:43 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59642) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zi29M-0007iu-3G for help-gnu-emacs@gnu.org; Fri, 02 Oct 2015 11:21:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zi29H-00089w-6u for help-gnu-emacs@gnu.org; Fri, 02 Oct 2015 11:21:32 -0400 Original-Received: from out4-smtp.messagingengine.com ([66.111.4.28]:33312) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zi29H-00089o-3E for help-gnu-emacs@gnu.org; Fri, 02 Oct 2015 11:21:27 -0400 Original-Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 98B51202EE for ; Fri, 2 Oct 2015 11:21:26 -0400 (EDT) Original-Received: from frontend2 ([10.202.2.161]) by compute5.internal (MEProxy); Fri, 02 Oct 2015 11:21:26 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=smtpout; bh=P8ZOKuDqpCIgZ4k6T1G3v1mfP8E=; b=tGwKI Q7NjYTAOvEuaVmG/4WG4f7ca6fVo65j2mooUL47xt0VEUtc+3rN9KqHc5ghBvfOT r+QlnUgXZMvdUP33azjrR7SDU8N63aXIH+RenFpqcKKlFEa1x4cXkao4CTVvLsfD MxNbS77s0Z6hTFrEUr4BCtkzu+hTvSXAolENsA= X-Sasl-enc: claTFFC2GCE9J1qqPT2bF2c0flmUW87LY5TIOUxnf6SR 1443799286 Original-Received: from thinkpad-t440p (unknown [2.161.209.103]) by mail.messagingengine.com (Postfix) with ESMTPA id F1299680170; Fri, 2 Oct 2015 11:21:25 -0400 (EDT) Mail-Followup-To: Stefan Monnier , help-gnu-emacs@gnu.org In-Reply-To: (Stefan Monnier's message of "Thu, 01 Oct 2015 20:10:12 -0400") User-Agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.28 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:107471 Archived-At: Stefan Monnier writes: >> `re-search-backward' already slow without LIMIT? > > Note that re-search-* performs a *search* whereas looking-at (and > looking-back) perform a *match*, which is expected to be quicker. > > re-search-* is implemented by performing a *match* at every position > and stop at the first where a match is encountered. I see, so (looking-back "foobar") will call (re-search-backward "\\(?:foobar\\)\\=") which in turn will at best (if point is just right of a foobar occurrence) move point backwards 6 times and perform a match each time. In the worst case (if we're not right of a foobar occurrence) point moves until (or LIMIT (point-min)) trying a match each time. So yes, I now get that `looking-back' is slow especially when no LIMIT near is given. And the extension if GREEDY is t is pretty much the same as what `re-search-*' does too (but of course in C), right? (But that `looking-back' concats the regex each while iteration is needless effort.) Bye, Tassilo