sideband.c: small optimization of strbuf usage
Signed-off-by: Nicolas Pitre <nico@fluxnic.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
5e5be9e257
commit
c61b2af7bd
@ -68,12 +68,12 @@ int recv_sideband(const char *me, int in_stream, int out)
|
|||||||
int linelen = brk - b;
|
int linelen = brk - b;
|
||||||
|
|
||||||
if (!outbuf.len)
|
if (!outbuf.len)
|
||||||
strbuf_addf(&outbuf, "%s", PREFIX);
|
strbuf_addstr(&outbuf, PREFIX);
|
||||||
if (linelen > 0) {
|
if (linelen > 0) {
|
||||||
strbuf_addf(&outbuf, "%.*s%s%c",
|
strbuf_addf(&outbuf, "%.*s%s%c",
|
||||||
linelen, b, suffix, *brk);
|
linelen, b, suffix, *brk);
|
||||||
} else {
|
} else {
|
||||||
strbuf_addf(&outbuf, "%c", *brk);
|
strbuf_addch(&outbuf, *brk);
|
||||||
}
|
}
|
||||||
xwrite(2, outbuf.buf, outbuf.len);
|
xwrite(2, outbuf.buf, outbuf.len);
|
||||||
strbuf_reset(&outbuf);
|
strbuf_reset(&outbuf);
|
||||||
@ -97,7 +97,7 @@ int recv_sideband(const char *me, int in_stream, int out)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (outbuf.len) {
|
if (outbuf.len) {
|
||||||
strbuf_addf(&outbuf, "\n");
|
strbuf_addch(&outbuf, '\n');
|
||||||
xwrite(2, outbuf.buf, outbuf.len);
|
xwrite(2, outbuf.buf, outbuf.len);
|
||||||
}
|
}
|
||||||
strbuf_release(&outbuf);
|
strbuf_release(&outbuf);
|
||||||
|
Reference in New Issue
Block a user