summaryrefslogtreecommitdiffstats
path: root/bin/sh/histedit.c
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2010-11-23 22:17:39 +0000
committerjilles <jilles@FreeBSD.org>2010-11-23 22:17:39 +0000
commit7377de8f916e2389e9f1c47ca8f7de558aaca6ef (patch)
treeff9e8102b66741a601dc54d4455bad759b583a8b /bin/sh/histedit.c
parent77837b201a907898ee7c79f6a8584102187a089a (diff)
downloadFreeBSD-src-7377de8f916e2389e9f1c47ca8f7de558aaca6ef.zip
FreeBSD-src-7377de8f916e2389e9f1c47ca8f7de558aaca6ef.tar.gz
sh: Code size optimizations to "stack string" memory allocation:
* Prefer one CHECKSTRSPACE with multiple USTPUTC to multiple STPUTC. * Add STPUTS macro (based on function) and use it instead of loops that add nul-terminated strings to the stack string. No functional change is intended, but code size is about 1K less on i386.
Diffstat (limited to 'bin/sh/histedit.c')
-rw-r--r--bin/sh/histedit.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/bin/sh/histedit.c b/bin/sh/histedit.c
index 3fc1782..26d46a8 100644
--- a/bin/sh/histedit.c
+++ b/bin/sh/histedit.c
@@ -411,8 +411,7 @@ fc_replace(const char *s, char *p, char *r)
STARTSTACKSTR(dest);
while (*s) {
if (*s == *p && strncmp(s, p, plen) == 0) {
- while (*r)
- STPUTC(*r++, dest);
+ STPUTS(r, dest);
s += plen;
*p = '\0'; /* so no more matches */
} else
OpenPOWER on IntegriCloud