param-parse: use g_string_append_c instead of g_string_append_printf
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 19 Nov 2019 16:22:42 +0000 (11:22 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 26 Nov 2019 19:24:17 +0000 (14:24 -0500)
... 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 <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2403
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
src/param-parse/param-parse.c

index 976b5bdf6dd083b5029fb065eeb06623633c63bd..e939e9abc606a83da5a0ff9bdd87429f367c466a 100644 (file)
@@ -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");
This page took 0.025169 seconds and 4 git commands to generate.