From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Arnold Noronha Newsgroups: gmane.emacs.bugs Subject: bug#41029: Improve ido-switch-buffer performance when many buffers are open Date: Sat, 2 May 2020 11:26:36 -0700 Message-ID: <20200502182636.GA9174@tdrhq.com> References: <20200502154055.GA11238@tdrhq.com> <20200502170521.GA17319@tdrhq.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="BOKacYhQ+x31HxR3" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="106573"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/1.10.1 (2018-07-13) To: 41029@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat May 02 20:27:32 2020 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 1jUwrM-000RdT-H5 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 02 May 2020 20:27:32 +0200 Original-Received: from localhost ([::1]:54938 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jUwrL-0005NE-GC for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 02 May 2020 14:27:31 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56490) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jUwqt-000570-SU for bug-gnu-emacs@gnu.org; Sat, 02 May 2020 14:27:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jUwqt-0003n9-7R for bug-gnu-emacs@gnu.org; Sat, 02 May 2020 14:27:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42360) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jUwqs-0003gi-5O for bug-gnu-emacs@gnu.org; Sat, 02 May 2020 14:27:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jUwqs-0000LV-0u for bug-gnu-emacs@gnu.org; Sat, 02 May 2020 14:27:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Arnold Noronha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 02 May 2020 18:27:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41029 X-GNU-PR-Package: emacs Original-Received: via spool by 41029-submit@debbugs.gnu.org id=B41029.15884440171317 (code B ref 41029); Sat, 02 May 2020 18:27:01 +0000 Original-Received: (at 41029) by debbugs.gnu.org; 2 May 2020 18:26:57 +0000 Original-Received: from localhost ([127.0.0.1]:53906 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jUwqa-0000Ky-MC for submit@debbugs.gnu.org; Sat, 02 May 2020 14:26:56 -0400 Original-Received: from tdrhq.com ([23.24.196.129]:57338) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jUwqY-0000Kj-UR for 41029@debbugs.gnu.org; Sat, 02 May 2020 14:26:43 -0400 Original-Received: by tdrhq.com (Postfix, from userid 1000) id F377CC20CB6; Sat, 2 May 2020 11:26:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tdrhq.com; s=201909; t=1588443997; bh=ui05vpZkccqLjkEOzUavKioMsA/PcoP9jsdtvieFU0k=; h=Date:From:To:Subject:References:In-Reply-To:From; b=s2pBGCz3kjBmMkkPbV+P0hEwjpSqYwvLAuIhxBGLt87CjAmDleBs12hx90CTnNNiK C8W+bcKLozssvNUnE8QRLxxju7RsOhs7ZyFvqcrYrrsdPt1YuSyAjyvF608DTgjzZY PxwxY2Dg2xReOndpSsq1f8FO22AZ3+RQ1U1IHtsZicH5eo7Mz9yYOquO9ybE619VXX NITh0ayH+0wziyYw4721tEZIImctj0KrBD0DY5f8oFgKXhsxKqc493e4LtWBBnCu0q edLCiqp7o+Znr5UNpJUVD9Et68Y+xq4RRUm1S0ZMlOW4k0sZYZhSdYlEOFZXR1TjZB v5qwjoIXxq2EQ== Content-Disposition: inline In-Reply-To: <20200502170521.GA17319@tdrhq.com> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:179534 Archived-At: --BOKacYhQ+x31HxR3 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Actually, I realized this could be cleaner. Nicer patch attached. --Arnold On Sat, May 02, 2020 at 10:05:21AM -0700, Arnold Noronha wrote: > > On Sat, May 02, 2020 at 08:40:55AM -0700, Arnold Noronha wrote: > > + (flet ((inner () > --BOKacYhQ+x31HxR3 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Use-a-temporary-buffer-before-calling-ido-ignore-ite.patch" >From 3dc513bc01decf9774f9ce5974abca30cbd71805 Mon Sep 17 00:00:00 2001 From: Arnold Noronha Date: Sat, 2 May 2020 11:24:22 -0700 Subject: [PATCH] Use a temporary-buffer before calling ido-ignore-item-p multiple times And locally set CASE-FOLD-SEARCH. Setting CASE-FOLD-SEARCH 1000s of times if CASE-FOLD-SEARCH is not locally set is super slow because it would have to update the bindings in each buffer (or, that is my understanding. See the warning at: https://www.gnu.org/software/emacs/manual/html_node/elisp/Intro-to-Buffer_002dLocal.html#Intro-to-Buffer_002dLocal) --- lisp/ido.el | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lisp/ido.el b/lisp/ido.el index 81883402ad..22b3729097 100644 --- a/lisp/ido.el +++ b/lisp/ido.el @@ -3407,13 +3407,18 @@ ido-make-merged-file-list (defun ido-make-buffer-list-1 (&optional frame visible) "Return list of non-ignored buffer names." - (delq nil - (mapcar - (lambda (x) - (let ((name (buffer-name x))) - (if (not (or (ido-ignore-item-p name ido-ignore-buffers) (member name visible))) - name))) - (buffer-list frame)))) + (with-temp-buffer + ;; Each call to ido-ignore-item-p LET-binds case-fold-search. + ;; That is slow if there's no buffer-local binding available, + ;; roughly O(number of buffers). This hack avoids it. + (setq-local case-fold-search nil) + (delq nil + (mapcar + (lambda (x) + (let ((name (buffer-name x))) + (if (not (or (ido-ignore-item-p name ido-ignore-buffers) (member name visible))) + name))) + (buffer-list frame))))) (defun ido-make-buffer-list (default) "Return the current list of buffers. -- 2.20.1 --BOKacYhQ+x31HxR3--