Subject: Re: bug#59787: 29.0.60; Very slow pos-visible-in-window-p with long truncated lines

From: Juri Linkov <[email-masked]>
Date: Wed, 07 Dec 2022 09:58:40 +0200

> As reported in https://debbugs.gnu.org/cgi/bugreport.cgi?bug=56682#1977:
>
>   2. after starting Isearch at a large column number,
>      Emacs hangs up indefinitely, e.g. with
>      'M-g TAB 10000000 RET C-s' then even C-g doesn't get out.
>      Debugging shows that the problem is in 'isearch-update'
>      where the call to 'pos-visible-in-window-group-p' doesn't return.
>      When this call is removed, the search is instantaneous.
>      (Optimizing lazy-highlight is a separate problem in bug#56815.)
>
> The problem is that pos-visible-in-window-p starts from window-start point
> and goes to the POSITION passed as argument using move_it_to, which in this
> case is very slow, because it has all the 10000000 columns to traverse.
>
> The solution is to introduce shortcuts into pos_visible_p in this case.

Could you explain why pos-visible-in-window-p is instantaneous at any
position when long lines are not truncated.  Why it doesn't need to
traverse 10000000 columns in this case?