diff options
author | jilles <jilles@FreeBSD.org> | 2010-11-23 22:17:39 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2010-11-23 22:17:39 +0000 |
commit | 7377de8f916e2389e9f1c47ca8f7de558aaca6ef (patch) | |
tree | ff9e8102b66741a601dc54d4455bad759b583a8b /bin/sh/miscbltin.c | |
parent | 77837b201a907898ee7c79f6a8584102187a089a (diff) | |
download | FreeBSD-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/miscbltin.c')
-rw-r--r-- | bin/sh/miscbltin.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/bin/sh/miscbltin.c b/bin/sh/miscbltin.c index d9ac8a3..dc200b6 100644 --- a/bin/sh/miscbltin.c +++ b/bin/sh/miscbltin.c @@ -172,11 +172,12 @@ readcmd(int argc __unused, char **argv __unused) } if (c == '\0') continue; + CHECKSTRSPACE(1, p); if (backslash) { backslash = 0; startword = 0; if (c != '\n') - STPUTC(c, p); + USTPUTC(c, p); continue; } if (!rflag && c == '\\') { @@ -194,14 +195,14 @@ readcmd(int argc __unused, char **argv __unused) if (is_ifs == 1) { /* Ignore leading IFS whitespace */ if (saveall) - STPUTC(c, p); + USTPUTC(c, p); continue; } if (is_ifs == 2 && startword == 1) { /* Only one non-whitespace IFS per word */ startword = 2; if (saveall) - STPUTC(c, p); + USTPUTC(c, p); continue; } } @@ -212,7 +213,7 @@ readcmd(int argc __unused, char **argv __unused) if (saveall) /* Not just a spare terminator */ saveall++; - STPUTC(c, p); + USTPUTC(c, p); continue; } @@ -222,7 +223,7 @@ readcmd(int argc __unused, char **argv __unused) if (ap[1] == NULL) { /* Last variable needs all IFS chars */ saveall++; - STPUTC(c, p); + USTPUTC(c, p); continue; } |