Re: [PATCH v4] Refactor recv_sideband()
On Wed, 29 Jun 2016, Junio C Hamano wrote:
Show 8 quoted lines
> Nicolas Pitre <nico@fluxnic.net> writes:
>
> > To make it clearer, here's a patch on top of pu that fixes all the
> > issues I think are remaining. All tests pass now.
>
> Lukas, can you see what is in 'pu' after I push out today's
> integration result in several hours and tell us if you like the
> result of the SQUASH??? change?
Here's a patch on top of it providing small optimizations.
----- >8
Subject: sideband.c: small optimization of strbuf usage
Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
diff --git a/sideband.c b/sideband.c
index 3cf3ced..b7e196b 100644
--- a/sideband.c
+++ b/sideband.c
@@ -68,12 +68,12 @@ int recv_sideband(const char *me, int in_stream, int out)
int linelen = brk - b;
if (!outbuf.len)
- strbuf_addf(&outbuf, "%s", PREFIX);
+ strbuf_addstr(&outbuf, PREFIX);
if (linelen > 0) {
strbuf_addf(&outbuf, "%.*s%s%c",
linelen, b, suffix, *brk);
} else {
- strbuf_addf(&outbuf, "%c", *brk);
+ strbuf_addch(&outbuf, *brk);
}
xwrite(2, outbuf.buf, outbuf.len);
strbuf_reset(&outbuf);
@@ -97,7 +97,7 @@ int recv_sideband(const char *me, int in_stream, int out)
}
if (outbuf.len) {
- strbuf_addf(&outbuf, "\n");
+ strbuf_addch(&outbuf, "\n");
xwrite(2, outbuf.buf, outbuf.len);
}
strbuf_release(&outbuf);