[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox-cvs
Subject:    [git commit] find: code shrink
From:       Denys Vlasenko <vda.linux () googlemail ! com>
Date:       2014-02-26 14:27:10
Message-ID: 20140226142737.BD0A39BAEC () busybox ! osuosl ! org
[Download RAW message or body]

commit: http://git.busybox.net/busybox/commit/?id=6885e49ba596239a0b0d3631fd72fc2692fbb65c
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master

function                                             old     new   delta
func_exec                                            306     285     -21

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
---
 findutils/find.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/findutils/find.c b/findutils/find.c
index 5d5e24b..044f010 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -420,12 +420,10 @@ static char* subst(const char *src, unsigned count, const char* filename)
 	size_t flen = strlen(filename);
 	/* we replace each '{}' with filename: growth by strlen-2 */
 	buf = dst = xmalloc(strlen(src) + count*(flen-2) + 1);
-	while ((end = strstr(src, "{}"))) {
-		memcpy(dst, src, end - src);
-		dst += end - src;
+	while ((end = strstr(src, "{}")) != NULL) {
+		dst = mempcpy(dst, src, end - src);
+		dst = mempcpy(dst, filename, flen);
 		src = end + 2;
-		memcpy(dst, filename, flen);
-		dst += flen;
 	}
 	strcpy(dst, src);
 	return buf;
_______________________________________________
busybox-cvs mailing list
busybox-cvs@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox-cvs
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic