[gtksourceview] bufferoutputstream: handle pathalogical fallback case



commit 80657810ef25726fdeb1b9ac7eb1d8756509d50c
Author: Christian Hergert <chergert redhat com>
Date:   Tue Aug 2 16:01:01 2022 -0700

    bufferoutputstream: handle pathalogical fallback case
    
    Avoid inserting really long lines in pathalogical insert_fallback() cases.
    This helps keep rendering performance okay in the presence of us inserting
    a bunch of fallback characters.
    
    Related #284

 gtksourceview/gtksourcebufferoutputstream.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
---
diff --git a/gtksourceview/gtksourcebufferoutputstream.c b/gtksourceview/gtksourcebufferoutputstream.c
index b87299cc..2816cb6d 100644
--- a/gtksourceview/gtksourcebufferoutputstream.c
+++ b/gtksourceview/gtksourcebufferoutputstream.c
@@ -612,7 +612,17 @@ insert_fallback (GtkSourceBufferOutputStream *stream,
                for (gsize i = 0; i < count; i++)
                {
                        guint8 c = ((const guint8 *)buffer)[i];
+
                        g_string_append_len (str, hex_fallback[c], 3);
+
+                       /* Add an occasional newline so that we are more
+                        * likely to not tank app performance.
+                        */
+                       if ((i+1) % 80 == 0)
+                       {
+                               g_string_append_c (str, '\n');
+                       }
+
                }
 
                gtk_text_buffer_insert (GTK_TEXT_BUFFER (stream->source_buffer),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]