From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: npostavs@gmail.com Newsgroups: gmane.emacs.bugs Subject: bug#35708: [27.0.50]: thingatpt.el, thing-at-point-looking-at redundant Date: Tue, 14 May 2019 10:34:55 -0400 Message-ID: <85tvdxw1dc.fsf@gmail.com> References: <8a73a0c9-5b38-4089-2780-28e62a1e162b@easy-emacs.de> <87ftpih6hs.fsf@gmail.com> <1bbebe25-9c4e-2563-701b-9bed85fcabb0@easy-emacs.de> <8536lixikt.fsf@gmail.com> <364b372e-7896-d92c-f848-0e7abc152a20@easy-emacs.de> <2d6578ec-8d7c-d3d0-7d1c-08eab22cae79@easy-emacs.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="226244"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.92 (windows-nt) Cc: 35708@debbugs.gnu.org, npostavs@gmail.com To: Andreas =?UTF-8?Q?R=C3=B6hler?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue May 14 16:39:12 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hQYaC-000wfU-EV for geb-bug-gnu-emacs@m.gmane.org; Tue, 14 May 2019 16:39:08 +0200 Original-Received: from localhost ([127.0.0.1]:49129 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQYaB-0003eH-Du for geb-bug-gnu-emacs@m.gmane.org; Tue, 14 May 2019 10:39:07 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:40004) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQYXE-0001Ze-BT for bug-gnu-emacs@gnu.org; Tue, 14 May 2019 10:36:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQYXC-0006dk-RR for bug-gnu-emacs@gnu.org; Tue, 14 May 2019 10:36:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36033) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hQYXC-0006db-Nf for bug-gnu-emacs@gnu.org; Tue, 14 May 2019 10:36:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hQYXC-0000IH-JL for bug-gnu-emacs@gnu.org; Tue, 14 May 2019 10:36:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: npostavs@gmail.com Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 14 May 2019 14:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35708 X-GNU-PR-Package: emacs Original-Received: via spool by 35708-submit@debbugs.gnu.org id=B35708.15578445101047 (code B ref 35708); Tue, 14 May 2019 14:36:02 +0000 Original-Received: (at 35708) by debbugs.gnu.org; 14 May 2019 14:35:10 +0000 Original-Received: from localhost ([127.0.0.1]:49575 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hQYWK-0000Gj-W5 for submit@debbugs.gnu.org; Tue, 14 May 2019 10:35:10 -0400 Original-Received: from mail-it1-f181.google.com ([209.85.166.181]:36827) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hQYWG-0000Fm-2E for 35708@debbugs.gnu.org; Tue, 14 May 2019 10:35:07 -0400 Original-Received: by mail-it1-f181.google.com with SMTP id e184so5051899ite.1 for <35708@debbugs.gnu.org>; Tue, 14 May 2019 07:35:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=oPM3PxnR7pCPltbaZwCfKCiDv/YsJCFG6SKcYZ6lXVs=; b=qRgqBLZJVBwQrANU5GxbEhCNjk8RX6OzF5FlQdlTB98XKL0Wb3rZcaf6RMVqadJEPE QN48omrUMKHfJ+XRU2EZvNsg24U20d+sFYzfBkdPTeEb/uUpjzOfAiGiBD3CJC0SWh6w 0npCqvP8GW5yJhkc1nBCJOJ70VxyJ5uV8ISMfNCV2MlPrbgHKw4brvNkFez2PfPFJ34q 8l8RxlpY6ygAWIddRKueCh/lGN6PpUr8UIKBAePVjetkaDy+vZE/2Xv0l2pbVDKYQ3bl VkEGFYh3iBg84mrU5hVxl57NPhsSWVacRAg2eRI1euVuh7HmpSj5AZg31foEFiOzCJO2 b2Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=oPM3PxnR7pCPltbaZwCfKCiDv/YsJCFG6SKcYZ6lXVs=; b=hsrVOZa5xsHECMHth92fkASG3WzVEWYeXTM4eberVnFbb6mecdNokyXQcWbuJlseWk xzUipN4gNmIQdgBdBXVzVTJ4hWmQi84gK7xSrogd72GJYUv9tHHvYGvtIDWysGnQT/pp H2KRLDmW+EBPoQ+y6ZZUkLf7MpuZ6EA/UIlwVjFWrAY3vgpBJCYQYLA12WlVTta3KJCg O9S4vP6vvDnF54MReuKvrA1UiQN+aSvduroK6ugcrQyzhc9QyqfxjykyzNbLAx+IJvh0 S2iA6o3hJdA797bRKdjWjMbCGFhMkMBi7/xHW730iG2G6WgGqNVQW1SQuX5qR+2Xqcgg stAQ== X-Gm-Message-State: APjAAAU4IJUsyGJVdQbzoTk9JS8QfdSn762RjNHAhT7/xZ2iICyL9PYi XDCC4yqKyL+ERtBgbeU/wboKE9OL X-Google-Smtp-Source: APXvYqy1B0fL558iP8WiYuft9JzTtEV2Hya4+Kx0yaz3V4vuLG1Z1VDQXH/h58CZQ2VUDQmPUJ+/IQ== X-Received: by 2002:a24:678e:: with SMTP id u136mr1278311itc.75.1557844498071; Tue, 14 May 2019 07:34:58 -0700 (PDT) Original-Received: from vhost2 (CPE001143542e1f-CMf81d0f809fa0.cpe.net.cable.rogers.com. [99.230.51.196]) by smtp.gmail.com with ESMTPSA id x77sm1245873ita.1.2019.05.14.07.34.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 May 2019 07:34:56 -0700 (PDT) In-Reply-To: <2d6578ec-8d7c-d3d0-7d1c-08eab22cae79@easy-emacs.de> ("Andreas \=\?iso-8859-1\?Q\?R\=F6hler\=22's\?\= message of "Tue, 14 May 2019 12:49:07 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:159274 Archived-At: Andreas R=C3=B6hler writes: >> Hmm, current thing-at-point-looking-at might be slow with large >> buffers. The slightly modified test should reveal it: >> >> (ert-deftest thing-at-point-looking-at-2 () >> =C2=A0 (with-temp-buffer >> =C2=A0=C2=A0=C2=A0 (insert "1abcd 222abcd") >> =C2=A0=C2=A0=C2=A0 (dotimes (_ 99999) (insert " asdf ")) >> =C2=A0=C2=A0=C2=A0 (goto-char (point-min)) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (search-forward "2ab") >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (should (thing-at-point-looking-at "2abcd= ")) Yes, in this case, since the loop over looking-at only needs to iterate twice, so it will be faster. But what about when there is no match? E.g., (with-temp-buffer (dotimes (_ 99999) (insert " asdf ")) (goto-char (point-max)) (list :ar-regexp-atpt (benchmark-run (ar-regexp-atpt "foo")) :thing-at-point-looking-at (benchmark-run (thing-at-point-looking-a= t "foo")))) > Another fix, as a bug showed up when testing (ar-regexp-atpt "[a-z]+"): > > (defun ar-regexp-atpt (regexp) > =C2=A0 "Return t if REGEXP matches at or before point, nil otherwise. > > Changes match-data" > =C2=A0 (save-excursion > =C2=A0=C2=A0=C2=A0 (if (looking-at regexp) > =C2=A0=C2=A0=C2=A0 (while > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 (and (not (bobp)) > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0(or (progn (backward-char) (l= ooking-at regexp)) > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 (forward-c= har 1)))) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (while (not (or (bobp) (backward-char) (lo= oking-at regexp)))) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (ar-regexp-atpt regexp)) What's this recursive call for? It triggers (error "Lisp nesting exceeds =E2=80=98max-lisp-eval-depth=E2=80=99") in the benchmark above. > =C2=A0=C2=A0=C2=A0 (looking-at regexp)))