[gnome-builder] build-tools: avoid va_args for property sets
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] build-tools: avoid va_args for property sets
- Date: Sat, 31 Dec 2016 03:29:37 +0000 (UTC)
commit db3a7dc72b56c2fb1dc18d1954c5861333e18dd9
Author: Christian Hergert <chergert redhat com>
Date: Fri Dec 30 19:29:10 2016 -0800
build-tools: avoid va_args for property sets
To avoid copying the string into a new GValue, we just create the gvalue
up front and allow it to own the generated string. This allows us to
also avoid the va_list g_object_set() calls for a very slight performance
improvement.
plugins/build-tools/gbp-build-panel.c | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/plugins/build-tools/gbp-build-panel.c b/plugins/build-tools/gbp-build-panel.c
index fe160ae..d875ef9 100644
--- a/plugins/build-tools/gbp-build-panel.c
+++ b/plugins/build-tools/gbp-build-panel.c
@@ -314,10 +314,15 @@ gbp_build_panel_text_func (GtkCellLayout *layout,
gpointer user_data)
{
g_autoptr(IdeDiagnostic) diagnostic = NULL;
+ g_auto(GValue) value = { 0 };
- gtk_tree_model_get (model, iter, 0, &diagnostic, -1);
+ gtk_tree_model_get (model, iter,
+ COLUMN_DIAGNOSTIC, &diagnostic,
+ -1);
+
+ g_value_init (&value, G_TYPE_STRING);
- if (diagnostic != NULL)
+ if G_LIKELY (diagnostic != NULL)
{
GString *str;
const gchar *text;
@@ -356,12 +361,13 @@ gbp_build_panel_text_func (GtkCellLayout *layout,
if (text != NULL)
g_string_append (str, text);
- g_object_set (renderer, "markup", str->str, NULL);
+ g_value_take_string (&value, g_string_free (str, FALSE));
+ g_object_set_property (G_OBJECT (renderer), "markup", &value);
- g_string_free (str, TRUE);
+ return;
}
- else
- g_object_set (renderer, "text", NULL, NULL);
+
+ g_object_set_property (G_OBJECT (renderer), "text", &value);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]