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

From: Michael Albinus <[email-masked]>
Date: Tue, 26 Sep 2023 16:18:12 +0200

Ihor Radchenko <[email-masked]> writes:

Hi Ihor,

>> With local files, it seems like insert-file-contents sets it.  So
>> maybe we should record the file name in the cache in bset_filename.
>
> Thanks for the pointer!
> AFAIU, the relevant code is
>
>       if (NILP (handler))
> 	{
> 	  current_buffer->modtime = mtime;
> 	  current_buffer->modtime_size = st.st_size;
> 	  bset_filename (current_buffer, orig_filename);
>
> However, it looks like file handlers are responsible for setting the
> filename. So,
>
> 	 >   - ~tramp-handle-insert-file-contents~
> 	 >   - ~tramp-archive-handle-insert-file-contents~
> 	 >   - ~ange-ftp-insert-file-contents~
> 	 >   - ~jka-compr-insert-file-contents~
> 	 >   - ~mm-url-insert-file-contents~
> 	 >   - ~epa-file-insert-file-contents~
>
> may also need to handle the caching. And also all the third-party handlers.

That might be hard to synchronize. Why not fill the cache after that
code snippet? The handlers have already done their job, buffer-file-name
is set. And so does bset_filename in the local case.

Best regards, Michael.