GNU bug report logs - #66117
30.0.50; `find-buffer-visiting' is slow when opening large number of buffers

Previous Next

Package: emacs;

Reported by: Ihor Radchenko <yantar92 <at> posteo.net>

Date: Wed, 20 Sep 2023 08:53:02 UTC

Severity: minor

Found in version 30.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ihor Radchenko <yantar92 <at> posteo.net>
Cc: dmitry <at> gutov.dev, 66117 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca
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
> From: Ihor Radchenko <yantar92 <at> posteo.net>
> Cc: monnier <at> iro.umontreal.ca, dmitry <at> gutov.dev, 66117 <at> 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.




This bug report was last modified 1 year and 135 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.