[gtksourceview/gnome-3-20] gutterrendererlines: remove allocations from ::query_data
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/gnome-3-20] gutterrendererlines: remove allocations from ::query_data
- Date: Sat, 23 Apr 2016 11:08:15 +0000 (UTC)
commit ab30ecc23462d285cd608d7e8f5df064166522cb
Author: Christian Hergert <christian hergert me>
Date: Wed Apr 20 18:37:47 2016 -0700
gutterrendererlines: remove allocations from ::query_data
This makes the cost of ::query_data() for the line gutter renderer
equivalent to the cost of the g_strdup_printf() previously.
https://bugzilla.gnome.org/show_bug.cgi?id=765356
gtksourceview/gtksourcegutterrendererlines.c | 16 +++++++---------
1 files changed, 7 insertions(+), 9 deletions(-)
---
diff --git a/gtksourceview/gtksourcegutterrendererlines.c b/gtksourceview/gtksourcegutterrendererlines.c
index fac2268..5a07102 100644
--- a/gtksourceview/gtksourcegutterrendererlines.c
+++ b/gtksourceview/gtksourcegutterrendererlines.c
@@ -88,19 +88,18 @@ recalculate_size (GtkSourceGutterRendererLines *renderer)
if (num_digits != renderer->priv->num_line_digits)
{
- gchar *markup;
+ gchar markup[24];
gint size;
renderer->priv->num_line_digits = num_digits;
num_lines = MAX (num_lines, 99);
- markup = g_strdup_printf ("<b>%d</b>", num_lines);
+ g_snprintf (markup, sizeof markup, "<b>%d</b>", num_lines);
gtk_source_gutter_renderer_text_measure_markup (GTK_SOURCE_GUTTER_RENDERER_TEXT (renderer),
markup,
&size,
NULL);
- g_free (markup);
gtk_source_gutter_renderer_set_size (GTK_SOURCE_GUTTER_RENDERER (renderer),
size);
@@ -196,8 +195,9 @@ gutter_renderer_query_data (GtkSourceGutterRenderer *renderer,
GtkTextIter *end,
GtkSourceGutterRendererState state)
{
- gchar *text;
+ gchar text[24];
gint line;
+ gint len;
gboolean current_line;
line = gtk_text_iter_get_line (start) + 1;
@@ -207,18 +207,16 @@ gutter_renderer_query_data (GtkSourceGutterRenderer *renderer,
if (current_line)
{
- text = g_strdup_printf ("<b>%d</b>", line);
+ len = g_snprintf (text, sizeof text, "<b>%d</b>", line);
}
else
{
- text = g_strdup_printf ("%d", line);
+ len = g_snprintf (text, sizeof text, "%d", line);
}
gtk_source_gutter_renderer_text_set_markup (GTK_SOURCE_GUTTER_RENDERER_TEXT (renderer),
text,
- -1);
-
- g_free (text);
+ len);
}
static gint
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]