From 5aac6542eced20ac37c921f79ba58b84e5909437 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Tue, 19 Nov 2019 11:22:42 -0500 Subject: [PATCH] param-parse: use g_string_append_c instead of g_string_append_printf ... to append a single character. I did some tests to evaluate the performance impact of this patch, in terms of number of instructions. I ran the following command line 20 times and computed the average and standard deviation of the number of execution instructions. $ libtool --mode=execute perf stat -e instructions:u ./src/cli/babeltrace2 query -p 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa=2,' src.ctf.fs yo average stdev Without this patch: 1079692 51 With this patch: 1039197 51 This represents a reduction of 3.75% in the number of executed instructions. Change-Id: I8109d42d0fa357e47642132a2f3b9581d72bcefa Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/2403 Reviewed-by: Philippe Proulx Tested-by: jenkins --- src/param-parse/param-parse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/param-parse/param-parse.c b/src/param-parse/param-parse.c index 976b5bdf..e939e9ab 100644 --- a/src/param-parse/param-parse.c +++ b/src/param-parse/param-parse.c @@ -96,7 +96,7 @@ void ini_append_error_expecting(struct ini_parsing_state *state, } for (i = 0; i < pos; ++i) { - g_string_append_printf(state->ini_error, " "); + g_string_append_c(state->ini_error, ' '); } g_string_append_printf(state->ini_error, "^\n\n"); -- 2.34.1