From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.bugs Subject: bug#51143: 29.0.50; Long delay after M-x commandname Date: Tue, 04 Oct 2022 00:40:54 +0200 Message-ID: <87a66czg21.fsf@web.de> References: <87ee8qcsfr.fsf@gnus.org> <87r1cq9hlf.fsf@gnus.org> <878rx6sr0c.fsf@gnus.org> <87bl22g1s8.fsf@web.de> <87pmg07qx6.fsf@gnus.org> <87y1uldl1t.fsf@web.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13617"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 51143@debbugs.gnu.org, Eduardo Ochs To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Oct 04 00:42:21 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ofU8j-0003Pu-3t for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 04 Oct 2022 00:42:21 +0200 Original-Received: from localhost ([::1]:56196 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ofU8i-0004TD-49 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 03 Oct 2022 18:42:20 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42308) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ofU8Q-0004RE-Jp for bug-gnu-emacs@gnu.org; Mon, 03 Oct 2022 18:42:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:52787) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ofU8Q-0004oV-CB for bug-gnu-emacs@gnu.org; Mon, 03 Oct 2022 18:42:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ofU8P-00066n-VO for bug-gnu-emacs@gnu.org; Mon, 03 Oct 2022 18:42:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Heerdegen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 03 Oct 2022 22:42:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51143 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 51143-submit@debbugs.gnu.org id=B51143.166483686323414 (code B ref 51143); Mon, 03 Oct 2022 22:42:01 +0000 Original-Received: (at 51143) by debbugs.gnu.org; 3 Oct 2022 22:41:03 +0000 Original-Received: from localhost ([127.0.0.1]:51865 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ofU7T-00065a-Fl for submit@debbugs.gnu.org; Mon, 03 Oct 2022 18:41:03 -0400 Original-Received: from mout.web.de ([212.227.15.4]:48273) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ofU7R-00064z-TX for 51143@debbugs.gnu.org; Mon, 03 Oct 2022 18:41:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1664836855; bh=A/9/vvGs01EdYWUDreqVa6yZ76Ne1vZ8npHwLgRtnaA=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date; b=Xqz40s3YWYLeU+rhX4p9Mj+t03OpJeaUVltI4XX+GrOjiXGz4eQbaoWy88FWbKxsZ 5er6xldP36eSib7YbUWCJg4incwxuaFrg2JkoSwBUEtQ5WaDhOSxuyJMGQIrWRBrNK eRV3OjrcpHSZ/VFvoUI5Ggd17uZdbT1rZRyySKsA/SCjHKphAcwV4DcErjAN9Rnt7/ 3Im3RUg/OfaZPKR6gjlhgv2UYLRzmn52TzKYtPqMTEDW3Ux6pOxbsBULKDi71bspNX SYwn3Gbc5+TiZ+exQjx9EFKK9q5tGWsp/qSBErwBhoGuIT1gkFjvt9tsxWxzEY2JQG QMo1hhsJh1B6w== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Original-Received: from drachen.dragon ([94.222.172.180]) by smtp.web.de (mrweb006 [213.165.67.108]) with ESMTPSA (Nemesis) id 1MjxiW-1p3nJ91Osy-00kc1U; Tue, 04 Oct 2022 00:40:55 +0200 In-Reply-To: <87y1uldl1t.fsf@web.de> (Michael Heerdegen's message of "Thu, 15 Sep 2022 11:49:34 +0200") X-Provags-ID: V03:K1:Z29QiPzPjxyBeqoC8L+b+9UN8qsUXaNkUvN4lmfOskSru4l9VJE aknXz3iFMGKGAgkLGW92pzW+8VP3Xj13eNHOGnnjVkmwVDQPNpdE1f8a1kWcy9mo/eDJ7Xz qu+AaYsxXZT3Fgp0oQNz4dY/qTySC0AjvFCNgnbGlY5TPmNtfWcz0GkaN0ngrdzKjxk1UgY tBJdQwQB9jG8xv7MF5ecA== X-UI-Out-Filterresults: notjunk:1;V03:K0:BwgjqnmPDBU=:g+8DY8bm79QjLrl3WoiIzh +Az3eKtC5Q0PBFmiDn8D3PjCvyTtuGMEDjUfPX4VwXz+nksL+Thug9ew40Q4zq34PzsjDSvvE +st0Ora3QfDG1IGgH5dFElTG4om1qkuqnHBHJRaZC9cFgCr1VBaKb5SkogYzd5vSqe0H8fq/0 twQNS+EOFtYTUd3l4Bc0E5zGvEzieIjqnJHQgwP5cpiuqRxFJt+LK0DhJCCJVxjvM8zXlzoR/ Co01Qux8J6nli4RCP1DzOjRC++NMukGmTpBS3YTFZQhg0ajp9f0bXfr92x2WGo9KhAZeT/3lX /Np0/9Wn0s30tojZN1LWOIB+WFdskZN1LJ/qzUljYeICsJOaz6+U9IzqPgBVVnHvAD4CcSsMC MmFo8Vsasdiruf3slJLmho5I8tMOTglE+/vRRmNwgXUIPz7127HNGp8qXz2kj1WG03Tv0W6Av P5TqiXtMbQQsC7vBrnzJRX8tGxPqOhmbJLAyqfezF7eu0j3N28D9yLsdXkTxkmWptxZ3VqMtF F89aQH8E/8mP0f3yDdI2VY2QpEdsExbGqT77nYoCkLz63qGIMTJ8xyGXpnoIh9DM+Pi6Ohbqn Szop/Foek06Kw43+nE1fcLLFr6WCv5YYPpoGVveG9Cc0GrbuxceuEQO1GpjmVoCkwDYJy30G9 NHSeroAd4Icqe1e11dMtTWKkE82bshGeNTlimQOq2G81CTwcyfIw7SYAGwI/qlFrRIb60kyoz UQR4ZCM/OAM/8bAs2tjX8wsxZw6fuOl+cl7HV1Co7qt0sWVSCrTfP8P6CMnAQpAkFepM3kDW X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:244338 Archived-At: --=-=-= Content-Type: text/plain Michael Heerdegen writes: > I remember what I had discussed with Stefan. The uncontroversial part > was to factor out the `commandp' tests out of > `completion-try-completion'. > > I'll have a look. This is what I have: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Try-to-speed-up-extended-command-shorthand-computati.patch Content-Transfer-Encoding: quoted-printable =46rom 6bc974197ff3e191971f933cc7f6fd952cdbba86 Mon Sep 17 00:00:00 2001 From: Michael Heerdegen Date: Sun, 18 Sep 2022 12:26:53 +0200 Subject: [PATCH] Try to speed up extended command shorthand computation * lisp/simple.el (execute-extended-command--shorter): Compute a complete list of `commandp' symbols once. This significantly speeds up complicated cases while the slowdown of simple cases is still accetable. =2D-- lisp/simple.el | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lisp/simple.el b/lisp/simple.el index 10a610e0c6..6724f3d6fc 100644 =2D-- a/lisp/simple.el +++ b/lisp/simple.el @@ -2465,9 +2465,13 @@ execute-extended-command--shorter-1 (defun execute-extended-command--shorter (name typed) (let ((candidates '()) + commands (max (length typed)) (len 1) binding) + ;; Precompute a list of commands once to avoid repeated `commandp' te= sting + ;; of symbols in the `completion-try-completion' call inside the loop= below + (mapatoms (lambda (s) (when (commandp s) (push s commands)))) (while (and (not binding) (progn (unless candidates @@ -2480,8 +2484,8 @@ execute-extended-command--shorter (input-pending-p) ;Dummy call to trigger input-processing, bug#2= 3002. (let ((candidate (pop candidates))) (when (equal name - (car-safe (completion-try-completion - candidate obarray 'commandp len))) + (car-safe (completion-try-completion + candidate commands nil len))) (setq binding candidate)))) binding)) =2D- 2.30.2 --=-=-= Content-Type: text/plain This speeds up computations of extended command shortcuts by a factor of around 4 in the complicated cases, while the slowdown for the easy cases is hardly noticeable. Maybe Eduardo can give that a try? Further improvements are probably not that low-hanging fruits. The calculation is also always interruptible so I don't think more work is worth the trouble. Michael. --=-=-=--