graph: use strbuf_addchars() to add spaces
strbuf_addf() can be used to add a specific number of space characters by using the format "%*s" with an empty string and specifying the desired width. Use strbuf_addchars() instead as it's shorter, makes the intent clearer and is a bit more efficient. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Oct 1, 2017 at 16:45 UTC
38bdf62b738bb93f7e1a6af8058dc31f27c91d4e
1 file changed
+3
-7
graph.c
+3
-7
@@ -696,12 +696,8 @@ static void graph_pad_horizontally(struct git_graph *graph, struct strbuf *sb,
696
* This way, fields printed to the right of the graph will remain
697
* aligned for the entire commit.
698
*/
699
- int extra;
700
- if (chars_written >= graph->width)
701
- return;
702
-
703
- extra = graph->width - chars_written;
704
- strbuf_addf(sb, "%*s", (int) extra, "");
699
+ if (chars_written < graph->width)
700
+ strbuf_addchars(sb, ' ', graph->width - chars_written);
701
}
702
703
static void graph_output_padding_line(struct git_graph *graph,
@@ -787,7 +783,7 @@ static void graph_output_pre_commit_line(struct git_graph *graph,
783
if (col->commit == graph->commit) {
784
seen_this = 1;
785
strbuf_write_column(sb, col, '|');
790
- strbuf_addf(sb, "%*s", graph->expansion_row, "");
786
+ strbuf_addchars(sb, ' ', graph->expansion_row);
787
chars_written += 1 + graph->expansion_row;
788
} else if (seen_this && (graph->expansion_row == 0)) {
789
/*