[gtksourceview] buffer: short-circuit bracket_highlight_timeout_cb()



commit 40b38354c247b5cdd3d9689ec60cce40e620c4da
Author: Christian Hergert <chergert redhat com>
Date:   Mon Aug 1 12:56:35 2022 -0700

    buffer: short-circuit bracket_highlight_timeout_cb()
    
    If we are not highlighting matching brackets, then we should just short-
    circuit and avoid the chance of doing too much work up-front.
    
    This can happen when loading large files with fallback characters such as
    binary files.
    
    Related GNOME/gnome-text-editor#444

 gtksourceview/gtksourcebuffer.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
---
diff --git a/gtksourceview/gtksourcebuffer.c b/gtksourceview/gtksourcebuffer.c
index ca36d846..de4fba49 100644
--- a/gtksourceview/gtksourcebuffer.c
+++ b/gtksourceview/gtksourcebuffer.c
@@ -974,6 +974,16 @@ queue_bracket_highlighting_update (GtkSourceBuffer *buffer)
 {
        GtkSourceBufferPrivate *priv = gtk_source_buffer_get_instance_private (buffer);
 
+       /* Short-circuit unless we're processing bracket highlighting. Since
+        * gtk_source_buffer_set_highlight_matching_brackets() will call
+        * update_bracket_highlighting() already, this short-circuit is safe
+        * as we'll already be in stable state.
+        */
+       if (priv->highlight_brackets == FALSE)
+       {
+               return;
+       }
+
        /* Rearm existing GSource when possible */
        if (priv->bracket_highlighting_timeout_id != 0)
        {


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