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

From: Dmitry Gutov <[email-masked]>
Date: Tue, 26 Sep 2023 14:11:06 +0300

On 24/09/2023 15:50, Eli Zaretskii wrote:
>>> ... if not, these functions are not relevant
>>> to the issue at hand.  If the search by truename_is_  significant, we
>>> could cache that as well.
>> Just to make sure that we are on the same page: the cache I am proposing
>> should be complete - if a buffer is missing from the cache, we should be
>> sure that there is no matching buffer.
> Since we will keep buffer-list (we must), even with this cache
> available, we can always leave the current code that scans the buffer
> list if the name is not in the cache.  This way, we don't need to
> worry to have all the buffers in the cache, only those which are
> looked for frequently and need the efficiency.

If the cache was exhaustive (i.e. we could guarantee that 
'find-buffer-visiting' is always fast), we could use it in Xref as well. 
Instead of doing the memoization dance in xref--find-file-buffer which 
still doesn't account for symlinks.