[gtksourceview] view: avoid g_object_get() in foreach callback



commit 58185d6c583f6d0ab68ffe4608b2c69d283727ce
Author: Christian Hergert <christian hergert me>
Date:   Sat Apr 23 19:00:13 2016 -0700

    view: avoid g_object_get() in foreach callback
    
    Remove some unnecessary strcmp() and property dispatch to determine if
    we should draw spaces. Additionally, this fixes a false positive where
    draw-spaces-set is TRUE but draw-spaces is FALSE.
    
    For good measure, we avoid the additional work when we've already found
    a match.

 gtksourceview/gtksourceview.c |   16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)
---
diff --git a/gtksourceview/gtksourceview.c b/gtksourceview/gtksourceview.c
index 5fb1dbc..3b58ab6 100644
--- a/gtksourceview/gtksourceview.c
+++ b/gtksourceview/gtksourceview.c
@@ -49,6 +49,7 @@
 #include "gtksourcegutterrenderermarks.h"
 #include "gtksourceiter.h"
 #include "gtksourcetag.h"
+#include "gtksourcetag-private.h"
 
 /**
  * SECTION:view
@@ -2447,17 +2448,14 @@ static void
 draw_spaces_tag_foreach (GtkTextTag *tag,
                         gboolean   *found)
 {
-       if (GTK_SOURCE_IS_TAG (tag))
+       if (*found == FALSE)
        {
-               gboolean draw_spaces_set;
-
-               g_object_get (tag,
-                             "draw-spaces-set", &draw_spaces_set,
-                             NULL);
-
-               if (draw_spaces_set)
+               if (GTK_SOURCE_IS_TAG (tag))
                {
-                       *found = TRUE;
+                       if (_gtk_source_tag_effects_spaces (GTK_SOURCE_TAG (tag)))
+                       {
+                               *found = TRUE;
+                       }
                }
        }
 }


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