Subject: bug#66117: 30.0.50; `find-buffer-visiting' is slow when opening large number of buffers

From: Stefan Monnier <[email-masked]>
Date: Thu, 14 Dec 2023 13:11:58 -0500

>> > But for starters, a new Lisp-only global variable should be good, I
>> > think.  Stefan, any comments?
>> 
>> I must say I don't understand the reasoning behind this.
>> What would it do different from `case-fold-search`?
>
> It won't be buffer-local-if-changed, so binding it will not be costly.

As mentioned elsewhere in this bug-report we can make `case-fold-search`
into a `DEFVAR_LISP`: it would have no visible impact to ELisp and would
avoid the costly let-bindings.

> It also won't be a defcustom, so let-binding it will not step on the
> user's preferences.

Hmm... when/where do existing let-bindings of `case-fold-search` step on
user settings of that var?

IME the problem is rather the opposite: most calls to search functions
don't explicitly let-bind `case-fold-search` and instead rely naively on
the default value and are thus susceptible to bugs if/when someone sets
the custom var (globally or buffer-locally).

        Stefan