From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Daniel Mendler Newsgroups: gmane.emacs.bugs Subject: bug#48738: [PATCH] Optimized `describe-variable' predicate Date: Sun, 30 May 2021 06:27:16 +0200 Message-ID: <55a7f6fc-ccad-a8e3-2f51-1cbc1555a4f8@daniel-mendler.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2E42C5D6DBA601563B9452CF" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4942"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Lars Ingebrigtsen To: 48738@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 30 06:28:11 2021 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 1lnD3a-000177-8s for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 30 May 2021 06:28:10 +0200 Original-Received: from localhost ([::1]:38336 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lnD3Z-0005kL-A2 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 30 May 2021 00:28:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44600) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lnD3S-0005kD-UM for bug-gnu-emacs@gnu.org; Sun, 30 May 2021 00:28:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46520) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lnD3S-0004NQ-Lj for bug-gnu-emacs@gnu.org; Sun, 30 May 2021 00:28:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lnD3S-0007pK-If for bug-gnu-emacs@gnu.org; Sun, 30 May 2021 00:28:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Daniel Mendler Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 30 May 2021 04:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 48738 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.162234884730041 (code B ref -1); Sun, 30 May 2021 04:28:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 30 May 2021 04:27:27 +0000 Original-Received: from localhost ([127.0.0.1]:58066 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lnD2t-0007oT-4z for submit@debbugs.gnu.org; Sun, 30 May 2021 00:27:27 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:54072) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lnD2p-0007oJ-NC for submit@debbugs.gnu.org; Sun, 30 May 2021 00:27:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44580) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lnD2p-0005jB-8k for bug-gnu-emacs@gnu.org; Sun, 30 May 2021 00:27:23 -0400 Original-Received: from server.qxqx.de ([2a01:4f8:121:346::180]:57621 helo=mail.qxqx.de) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lnD2n-0003ns-34 for bug-gnu-emacs@gnu.org; Sun, 30 May 2021 00:27:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=qxqx.de; s=mail1392553390; h=Content-Type:MIME-Version:Date:Message-ID:Subject:From:Cc :To:Sender:Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=z31ecgYbh+r9oIN//SMlsCGBXLAQ8eFYK3lXZN92GyE=; b=sQ713MPikNHt0J9aTmyhr3sJwT bmk7pW+fhDca4E8ycHJCRrDyJKFrT7pez1QD4DWtmq/0dS5+4bwBDUQWWAyfcC5SDAQOAltYdfYFf QEMup8WtSfaKvrOLuhZ/1mr8y2yZSuUIWF2SUfJc28x9I5qyr3xNKafCSQZLNDhmDraE=; Content-Language: en-US Received-SPF: pass client-ip=2a01:4f8:121:346::180; envelope-from=mail@daniel-mendler.de; helo=mail.qxqx.de X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:207569 Archived-At: This is a multi-part message in MIME format. --------------2E42C5D6DBA601563B9452CF Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Do not switch to the original buffer. Use `buffer-local-value` instead. The buffer switching is more costly, which slows down continuously updating completion UIs like Icomplete or Vertico if there are many variables. Ideally there would be a `buffer-local-boundp` predicate we could use here. In GNU Emacs 28.0.50 (build 12, x86_64-pc-linux-gnu, GTK+ Version 3.24.5, cairo version 1.16.0) of 2021-05-23 built on projects Windowing system distributor 'The X.Org Foundation', version 11.0.12004000 System Description: Debian GNU/Linux 10 (buster) --------------2E42C5D6DBA601563B9452CF Content-Type: text/x-diff; charset=UTF-8; name="0001-describe-variable-Do-not-switch-to-the-original-buff.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-describe-variable-Do-not-switch-to-the-original-buff.pa"; filename*1="tch" >From 9100bce6f057787df9f255a9bb98f37bbef44940 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Sun, 30 May 2021 06:16:17 +0200 Subject: [PATCH] (describe-variable): Do not switch to the original buffer in the predicate Do not switch to the original buffer. Use `buffer-local-value` instead. The buffer switching is more costly, which slows down continuously updating completion UIs like Icomplete or Vertico if there are many variables. * lisp/help-fns.el (describe-variable): Use optimized predicate. --- lisp/help-fns.el | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lisp/help-fns.el b/lisp/help-fns.el index 0b0ae4364c..46ace6bd24 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -1022,12 +1022,14 @@ describe-variable (format-prompt "Describe variable" (and (symbolp v) v)) #'help--symbol-completion-table (lambda (vv) - ;; In case the variable only exists in the buffer - ;; the command we switch back to that buffer before - ;; we examine the variable. - (with-current-buffer orig-buffer - (or (get vv 'variable-documentation) - (and (boundp vv) (not (keywordp vv)))))) + (or (get vv 'variable-documentation) + (and (not (keywordp vv)) + ;; Since the variable may only exists in + ;; the original buffer, we have to look for + ;; it there. + (ignore-errors + (or (buffer-local-value vv orig-buffer) + t))))) t nil nil (if (symbolp v) (symbol-name v)))) (list (if (equal val "") -- 2.20.1 --------------2E42C5D6DBA601563B9452CF--