Subject: Re: bug#57207: 29.0.50; Fontification is slow after e7b5912b23 (Improvements to long lines handling)

From: Eli Zaretskii <[email-masked]>
Date: Mon, 15 Aug 2022 20:08:27 +0300

> Cc: [email-masked], [email-masked]
> Date: Mon, 15 Aug 2022 17:28:44 +0300
> From: Eli Zaretskii <[email-masked]>
> 
> Can you tell some statistics about the lines in that file:
> 
>   . how many lines?
>   . how many lines longer than 10000 characters?
>   . how many lines longer than 100000 characters?
> 
> And finally, can you post a short enough Org file, but long enough to
> exhibit the features you need to do the "unfolding headlines hidden
> using 'invisible text property" thing?  And also tell which Org
> commands you invoke to do that unfolding?  Because I don't think I
> understand what exactly are you doing in Org to trigger this, and thus
> I cannot try reproducing it.

Does the patch below fix the issue?

diff --git a/src/xdisp.c b/src/xdisp.c
index 0248e8e..03c43be 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -19589,7 +19589,7 @@ redisplay_window (Lisp_Object window, bool just_this_one_p)
     {
       ptrdiff_t cur, next, found, max = 0, threshold;
       threshold = XFIXNUM (Vlong_line_threshold);
-      for (cur = BEG; cur < Z; cur = next)
+      for (cur = BEGV; cur < ZV; cur = next)
 	{
 	  next = find_newline1 (cur, CHAR_TO_BYTE (cur), 0, -1, 1,
 				&found, NULL, true);