[git commit] nmeter: code shrink

Denys Vlasenko vda.linux at googlemail.com
Tue Mar 15 14:28:49 UTC 2016


commit: https://git.busybox.net/busybox/commit/?id=99c71c9e800d51aa52d7bd592e8071341013a628
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

function                                             old     new   delta
put                                                   52      43      -9

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 procps/nmeter.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/procps/nmeter.c b/procps/nmeter.c
index 0ce6842..8fe39c4 100644
--- a/procps/nmeter.c
+++ b/procps/nmeter.c
@@ -142,11 +142,11 @@ static void print_outbuf(void)
 
 static void put(const char *s)
 {
-	int sz = strlen(s);
-	if (sz > outbuf + sizeof(outbuf) - cur_outbuf)
-		sz = outbuf + sizeof(outbuf) - cur_outbuf;
-	memcpy(cur_outbuf, s, sz);
-	cur_outbuf += sz;
+	char *p = cur_outbuf;
+	int sz = outbuf + sizeof(outbuf) - p;
+	while (*s && --sz >= 0)
+		*p++ = *s++;
+	cur_outbuf = p;
 }
 
 static void put_c(char c)


More information about the busybox-cvs mailing list