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

From: Eli Zaretskii <[email-masked]>
Date: Sat, 30 Dec 2023 13:07:10 +0200

> From: Ihor Radchenko <[email-masked]>
> Cc: [email-masked], [email-masked], [email-masked]
> Date: Sat, 30 Dec 2023 10:39:49 +0000
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> > I think at least part of the problem is in this fragment from
> > find-file-noselect:
> >
> > 	     ;; Find any buffer for a file that has same truename.
> > 	     (other (and (not buf)
> >                          (find-buffer-visiting
> >                           filename
> >                           ;; We want to filter out buffers that we've
> >                           ;; visited via symlinks and the like, where
> >                           ;; the symlink no longer exists.
> >                           (lambda (buffer)
> >                             (let ((file (buffer-local-value
> >                                          'buffer-file-name buffer)))
> >                               (and file (file-exists-p file))))))))
> 
> Not this one - (and file ...) will never trigger when file is nil.

Granted, that call to file-exists-p was not what I meant.

> I think I found the problem - it is rather silly.
> See the attached patch.

Thanks, installed.