strbuf: use strbuf_addchars() for adding a char multiple times
Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
d07235a027
commit
415792edf5
5
graph.c
5
graph.c
@ -1145,7 +1145,7 @@ int graph_next_line(struct git_graph *graph, struct strbuf *sb)
|
|||||||
|
|
||||||
static void graph_padding_line(struct git_graph *graph, struct strbuf *sb)
|
static void graph_padding_line(struct git_graph *graph, struct strbuf *sb)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i;
|
||||||
|
|
||||||
if (graph->state != GRAPH_COMMIT) {
|
if (graph->state != GRAPH_COMMIT) {
|
||||||
graph_next_line(graph, sb);
|
graph_next_line(graph, sb);
|
||||||
@ -1169,8 +1169,7 @@ static void graph_padding_line(struct git_graph *graph, struct strbuf *sb)
|
|||||||
strbuf_addch(sb, ' ');
|
strbuf_addch(sb, ' ');
|
||||||
else {
|
else {
|
||||||
int num_spaces = ((graph->num_parents - 2) * 2);
|
int num_spaces = ((graph->num_parents - 2) * 2);
|
||||||
for (j = 0; j < num_spaces; j++)
|
strbuf_addchars(sb, ' ', num_spaces);
|
||||||
strbuf_addch(sb, ' ');
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
strbuf_write_column(sb, col, '|');
|
strbuf_write_column(sb, col, '|');
|
||||||
|
@ -163,9 +163,7 @@ static void output(struct merge_options *o, int v, const char *fmt, ...)
|
|||||||
if (!show(o, v))
|
if (!show(o, v))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
strbuf_grow(&o->obuf, o->call_depth * 2 + 2);
|
strbuf_addchars(&o->obuf, ' ', o->call_depth * 2);
|
||||||
memset(o->obuf.buf + o->obuf.len, ' ', o->call_depth * 2);
|
|
||||||
strbuf_setlen(&o->obuf, o->obuf.len + o->call_depth * 2);
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
strbuf_vaddf(&o->obuf, fmt, ap);
|
strbuf_vaddf(&o->obuf, fmt, ap);
|
||||||
|
10
pretty.c
10
pretty.c
@ -1400,9 +1400,7 @@ static size_t format_and_pad_commit(struct strbuf *sb, /* in UTF-8 */
|
|||||||
* convert it back to chars
|
* convert it back to chars
|
||||||
*/
|
*/
|
||||||
padding = padding - len + local_sb.len;
|
padding = padding - len + local_sb.len;
|
||||||
strbuf_grow(sb, padding);
|
strbuf_addchars(sb, ' ', padding);
|
||||||
strbuf_setlen(sb, sb_len + padding);
|
|
||||||
memset(sb->buf + sb_len, ' ', sb->len - sb_len);
|
|
||||||
memcpy(sb->buf + sb_len + offset, local_sb.buf,
|
memcpy(sb->buf + sb_len + offset, local_sb.buf,
|
||||||
local_sb.len);
|
local_sb.len);
|
||||||
}
|
}
|
||||||
@ -1679,10 +1677,8 @@ void pp_remainder(struct pretty_print_context *pp,
|
|||||||
first = 0;
|
first = 0;
|
||||||
|
|
||||||
strbuf_grow(sb, linelen + indent + 20);
|
strbuf_grow(sb, linelen + indent + 20);
|
||||||
if (indent) {
|
if (indent)
|
||||||
memset(sb->buf + sb->len, ' ', indent);
|
strbuf_addchars(sb, ' ', indent);
|
||||||
strbuf_setlen(sb, sb->len + indent);
|
|
||||||
}
|
|
||||||
strbuf_add(sb, line, linelen);
|
strbuf_add(sb, line, linelen);
|
||||||
strbuf_addch(sb, '\n');
|
strbuf_addch(sb, '\n');
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user