From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#66117: 30.0.50; `find-buffer-visiting' is slow when opening large number of buffers Date: Wed, 13 Dec 2023 15:51:39 +0200 Message-ID: <83fs06rz10.fsf@gnu.org> References: <878r919qfh.fsf@localhost> <87il7izo4l.fsf@localhost> <831qe61xrh.fsf@gnu.org> <87cyxqzmhh.fsf@localhost> <83zg0uzlgw.fsf@gnu.org> <87v8bhxzcu.fsf@localhost> <83y1gdxws8.fsf@gnu.org> <87jzrwm7ul.fsf@localhost> <87h6n0m781.fsf@localhost> <87v8935wik.fsf@localhost> <83msuftr0i.fsf@gnu.org> <87plzbxtxa.fsf@localhost> <87y1dzvvf0.fsf@localhost> <83plzas3pg.fsf@gnu.org> <87r0jqw8u9.fsf@localhost> <83jzpis08a.fsf@gnu.org> <87il52w744.fsf@localhost> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26954"; mail-complaints-to="usenet@ciao.gmane.io" Cc: dmitry@gutov.dev, 66117@debbugs.gnu.org, monnier@iro.umontreal.ca To: Ihor Radchenko Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Dec 13 14:53:12 2023 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 1rDPfk-0006nD-2V for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 Dec 2023 14:53:12 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rDPfN-00072a-5y; Wed, 13 Dec 2023 08:52:49 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rDPfK-000722-LV for bug-gnu-emacs@gnu.org; Wed, 13 Dec 2023 08:52:46 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rDPfK-0003la-D1 for bug-gnu-emacs@gnu.org; Wed, 13 Dec 2023 08:52:46 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rDPfa-0006mX-BO for bug-gnu-emacs@gnu.org; Wed, 13 Dec 2023 08:53:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 Dec 2023 13:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66117 X-GNU-PR-Package: emacs Original-Received: via spool by 66117-submit@debbugs.gnu.org id=B66117.170247552925990 (code B ref 66117); Wed, 13 Dec 2023 13:53:02 +0000 Original-Received: (at 66117) by debbugs.gnu.org; 13 Dec 2023 13:52:09 +0000 Original-Received: from localhost ([127.0.0.1]:58446 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rDPei-0006l7-S1 for submit@debbugs.gnu.org; Wed, 13 Dec 2023 08:52:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54590) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rDPeg-0006kY-ED for 66117@debbugs.gnu.org; Wed, 13 Dec 2023 08:52:07 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rDPeJ-0003fw-VA; Wed, 13 Dec 2023 08:51:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=hHPm8IP2VzNRE1/9ZoilHbYP4ueBMwb5gf1xUMsmE7c=; b=J1WRC1dm+e8U bLJ1WdFuXc6U1UDpUM6dXcEr05HigfUvSVAtRTMK9JQhHNaKusXyBfB3imLWthVXstoDOT0C0Dn5k MlDKu4W4uNC/AGu3/46MpTLS21xk1ECJ+BToXeAmmIh7CT6h7c3LuP5VgXA68FTRVnsdbyIm/XSPM 3DXtygWcWyk6PtRLCVrxzIkIa0e5JXSDWhqTCfcN/9vmTaOWtXobNRZugEhhtJ9xBVt3s8bSRsmLI whW6nPIAjh1yy70xG1t+nMg0b/jKNW0C70U4lpUxE9lns2/eQrvIbs1AO5OnbHft/MTJvxlepoUWt b5j4ImvrOyoLQLiBFt2IGQ==; In-Reply-To: <87il52w744.fsf@localhost> (message from Ihor Radchenko on Wed, 13 Dec 2023 13:43:23 +0000) 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:276131 Archived-At: > From: Ihor Radchenko > Cc: monnier@iro.umontreal.ca, dmitry@gutov.dev, 66117@debbugs.gnu.org > Date: Wed, 13 Dec 2023 13:43:23 +0000 > > The simplest solution would be what `ido-make-buffer-list-1' does: > > ;; 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) > > But it will only solve specific problem with `find-buffer-visiting' and > we can always go for it if we cannot find anything better. Which other popular functions need to loop through all the buffers in Lisp? > I thought that trying to solve a more general problem would benefit more > code - let-binding case-fold-search is extremely common across packages. IMO, the general way you are trying to solve this makes this a very hard problem with potentially Emacs-wide implications. So we might as well look for easier alternatives. We could, for example, document the above trick, for those who need it. Or we could have a separate variable, which would not be a defcustom nor automatically buffer-local, and will have the same effect as case-fold-search on low-level searching and matching functions. Btw, are you aware that many case-insensitive operations in Emacs depend also on the case table in effect, which can also be buffer-local? So case-insensitive operations in Lisp can be unexpectedly affected by stuff like the current buffer. One more reason to use them as little as possible.