diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2014-02-26 15:27:10 +0100 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2014-02-26 15:27:10 +0100 |
| commit | 6885e49ba596239a0b0d3631fd72fc2692fbb65c (patch) | |
| tree | b48310d6f49b1d3c78cfafda5450b65455fbe355 | |
| parent | c472898eaa0ccc1d4d787ae1917a8f40d18889cb (diff) | |
| download | busybox-w32-6885e49ba596239a0b0d3631fd72fc2692fbb65c.tar.gz busybox-w32-6885e49ba596239a0b0d3631fd72fc2692fbb65c.tar.bz2 busybox-w32-6885e49ba596239a0b0d3631fd72fc2692fbb65c.zip | |
find: code shrink
function old new delta
func_exec 306 285 -21
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| -rw-r--r-- | findutils/find.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/findutils/find.c b/findutils/find.c index 5d5e24bfb..044f010b0 100644 --- a/findutils/find.c +++ b/findutils/find.c | |||
| @@ -420,12 +420,10 @@ static char* subst(const char *src, unsigned count, const char* filename) | |||
| 420 | size_t flen = strlen(filename); | 420 | size_t flen = strlen(filename); |
| 421 | /* we replace each '{}' with filename: growth by strlen-2 */ | 421 | /* we replace each '{}' with filename: growth by strlen-2 */ |
| 422 | buf = dst = xmalloc(strlen(src) + count*(flen-2) + 1); | 422 | buf = dst = xmalloc(strlen(src) + count*(flen-2) + 1); |
| 423 | while ((end = strstr(src, "{}"))) { | 423 | while ((end = strstr(src, "{}")) != NULL) { |
| 424 | memcpy(dst, src, end - src); | 424 | dst = mempcpy(dst, src, end - src); |
| 425 | dst += end - src; | 425 | dst = mempcpy(dst, filename, flen); |
| 426 | src = end + 2; | 426 | src = end + 2; |
| 427 | memcpy(dst, filename, flen); | ||
| 428 | dst += flen; | ||
| 429 | } | 427 | } |
| 430 | strcpy(dst, src); | 428 | strcpy(dst, src); |
| 431 | return buf; | 429 | return buf; |
