[gtksourceview/wip/chergert/backport-fixes-for-pathological-data: 2/2] bufferoutputstream: handle pathalogical fallback case
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/backport-fixes-for-pathological-data: 2/2] bufferoutputstream: handle pathalogical fallback case
- Date: Wed, 3 Aug 2022 05:16:59 +0000 (UTC)
commit 4f223a98a2168161b534a984e07ed7e58f0bb3b6
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 44d6f7fa..2756a3c0 100644
--- a/gtksourceview/gtksourcebufferoutputstream.c
+++ b/gtksourceview/gtksourcebufferoutputstream.c
@@ -615,7 +615,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->priv->source_buffer),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]