Subject: bug#78520: 31.0.50; Performance issue in dired+isearch with dired-isearch-filenames

From: Juri Linkov <[email-masked]>
Date: Tue, 03 Jun 2025 18:25:33 +0300

> I did not face errors so far but... is it now really faster than before?
> I tried M-s f C-s in a huge dired buffer in emacs -Q, and it was
> horribly slow.  Slower than with the hack I had been using.  I did not
> yet try to have a closer look at your code I must admit.  Did you see a
> speed improvement?

I'm using C-s in large Dired buffers all the time, and before the patch
the search lags were too long (~2 sec on every match).  But now with
the patch the search is instantaneous even on very large Dired buffers.

The search might be still slow only on one very rare case:
when the search string also occurs outside of file names.
For example, when the Dired contains permissions "-rw-r--r--",
then searching for "r" or "rw" will be slow.

Do we need more optimization for such rare cases?

This is possible to do by adding the same code that you suggested
not only before the 'while' loop, but also at the end of every
iteration inside the 'while' loop.  But this will overcomplicate
the function 'search-within-boundaries'.