[gtksourceview] map: avoid string copy when reloading CSS



commit 41aa5360558ac13f840e30237eef0f0f1d7cb2d2
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jun 21 17:24:30 2021 -0700

    map: avoid string copy when reloading CSS

 gtksourceview/gtksourcemap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/gtksourceview/gtksourcemap.c b/gtksourceview/gtksourcemap.c
index c2b3549b..3144e49e 100644
--- a/gtksourceview/gtksourcemap.c
+++ b/gtksourceview/gtksourcemap.c
@@ -401,7 +401,8 @@ gtk_source_map_rebuild_css (GtkSourceMap *map)
 
        if (gstr->len > 0)
        {
-               gtk_css_provider_load_from_data (priv->css_provider, gstr->str, gstr->len);
+               /* use -1 to avoid a copy of the string */
+               gtk_css_provider_load_from_data (priv->css_provider, gstr->str, -1);
        }
 
        g_string_free (gstr, TRUE);


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