From: Mathieu Desnoyers Date: Mon, 17 Jun 2019 19:33:51 +0000 (-0400) Subject: sink.text.pretty: do not printf field name strings X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=93a630c7e3f0d606f54806fbd284396ff37e0154 sink.text.pretty: do not printf field name strings Use g_string_append rather than the printf counterpart to output field name strings. This significantly improves pretty printing speed (34s -> 29s on reference trace). This is a performance improvement mainly because only strings are passed to printf in this case. Signed-off-by: Mathieu Desnoyers Change-Id: I4df52308c61346a81e0b79b079d53be52084707f Reviewed-on: https://review.lttng.org/c/babeltrace/+/1504 CI-Build: Philippe Proulx Tested-by: jenkins Reviewed-by: Francis Deslauriers Reviewed-by: Philippe Proulx --- diff --git a/src/plugins/text/pretty/print.c b/src/plugins/text/pretty/print.c index 5803d4fc..c882e76b 100644 --- a/src/plugins/text/pretty/print.c +++ b/src/plugins/text/pretty/print.c @@ -60,22 +60,26 @@ static void print_name_equal(struct pretty_component *pretty, const char *name) { if (pretty->use_colors) { - bt_common_g_string_append_printf(pretty->string, "%s%s%s = ", COLOR_NAME, - name, COLOR_RST); + g_string_append(pretty->string, COLOR_NAME); + g_string_append(pretty->string, name); + g_string_append(pretty->string, COLOR_RST); } else { - bt_common_g_string_append_printf(pretty->string, "%s = ", name); + g_string_append(pretty->string, name); } + g_string_append(pretty->string, " = "); } static void print_field_name_equal(struct pretty_component *pretty, const char *name) { if (pretty->use_colors) { - bt_common_g_string_append_printf(pretty->string, "%s%s%s = ", - COLOR_FIELD_NAME, name, COLOR_RST); + g_string_append(pretty->string, COLOR_FIELD_NAME); + g_string_append(pretty->string, name); + g_string_append(pretty->string, COLOR_RST); } else { - bt_common_g_string_append_printf(pretty->string, "%s = ", name); - } + g_string_append(pretty->string, name); +} + g_string_append(pretty->string, " = "); } static