diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2016-10-26 16:41:13 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2016-10-26 16:41:13 +0200 |
commit | 3df1410a00a7a57f3a43373c00cdea2031d7d70c (patch) | |
tree | 39860518a919b8e52cbca84cc34eab6ef125a618 /shell | |
parent | 350e686f3b04f41f623316706094f0e18a10c1cf (diff) | |
download | busybox-w32-3df1410a00a7a57f3a43373c00cdea2031d7d70c.tar.gz busybox-w32-3df1410a00a7a57f3a43373c00cdea2031d7d70c.tar.bz2 busybox-w32-3df1410a00a7a57f3a43373c00cdea2031d7d70c.zip |
ash: [PARSER] Size optimisations in parameter expansion parser
Upstream commit:
Date: Thu, 4 Oct 2007 22:20:38 +0800
[PARSER] Size optimisations in parameter expansion parser
Merge flags into subtype.
Do not write subtype out twice.
Add likely flag on ${ vs. $NAME.
Kill unnecessary (and bogus) PEOA check.
function old new delta
readtoken1 2891 2860 -31
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/shell/ash.c b/shell/ash.c index e0828d4a7..21373b65a 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -11701,7 +11701,6 @@ parseredir: { | |||
11701 | parsesub: { | 11701 | parsesub: { |
11702 | unsigned char subtype; | 11702 | unsigned char subtype; |
11703 | int typeloc; | 11703 | int typeloc; |
11704 | int flags = 0; | ||
11705 | 11704 | ||
11706 | c = pgetc_eatbnl(); | 11705 | c = pgetc_eatbnl(); |
11707 | if (c > 255 /* PEOA or PEOF */ | 11706 | if (c > 255 /* PEOA or PEOF */ |
@@ -11730,19 +11729,19 @@ parsesub: { | |||
11730 | /* $VAR, $<specialchar>, ${...}, or PEOA/PEOF */ | 11729 | /* $VAR, $<specialchar>, ${...}, or PEOA/PEOF */ |
11731 | USTPUTC(CTLVAR, out); | 11730 | USTPUTC(CTLVAR, out); |
11732 | typeloc = out - (char *)stackblock(); | 11731 | typeloc = out - (char *)stackblock(); |
11733 | USTPUTC(VSNORMAL, out); | 11732 | STADJUST(1, out); |
11734 | subtype = VSNORMAL; | 11733 | subtype = VSNORMAL; |
11735 | if (c == '{') { | 11734 | if (c == '{') { |
11736 | c = pgetc_eatbnl(); | 11735 | c = pgetc_eatbnl(); |
11737 | subtype = 0; | 11736 | subtype = 0; |
11738 | } | 11737 | } |
11739 | varname: | 11738 | varname: |
11740 | if (c <= 255 /* not PEOA or PEOF */ && is_name(c)) { | 11739 | if (is_name(c)) { |
11741 | /* $[{[#]]NAME[}] */ | 11740 | /* $[{[#]]NAME[}] */ |
11742 | do { | 11741 | do { |
11743 | STPUTC(c, out); | 11742 | STPUTC(c, out); |
11744 | c = pgetc_eatbnl(); | 11743 | c = pgetc_eatbnl(); |
11745 | } while (c <= 255 /* not PEOA or PEOF */ && is_in_name(c)); | 11744 | } while (is_in_name(c)); |
11746 | } else if (isdigit(c)) { | 11745 | } else if (isdigit(c)) { |
11747 | /* $[{[#]]NUM[}] */ | 11746 | /* $[{[#]]NUM[}] */ |
11748 | do { | 11747 | do { |
@@ -11776,7 +11775,6 @@ parsesub: { | |||
11776 | goto badsub; | 11775 | goto badsub; |
11777 | } | 11776 | } |
11778 | 11777 | ||
11779 | flags = 0; | ||
11780 | if (subtype == 0) { | 11778 | if (subtype == 0) { |
11781 | static const char types[] ALIGN1 = "}-+?="; | 11779 | static const char types[] ALIGN1 = "}-+?="; |
11782 | /* ${VAR...} but not $VAR or ${#VAR} */ | 11780 | /* ${VAR...} but not $VAR or ${#VAR} */ |
@@ -11795,13 +11793,13 @@ parsesub: { | |||
11795 | break; /* "goto badsub" is bigger (!) */ | 11793 | break; /* "goto badsub" is bigger (!) */ |
11796 | } | 11794 | } |
11797 | #endif | 11795 | #endif |
11798 | flags = VSNUL; | 11796 | subtype = VSNUL; |
11799 | /*FALLTHROUGH*/ | 11797 | /*FALLTHROUGH*/ |
11800 | default: { | 11798 | default: { |
11801 | const char *p = strchr(types, c); | 11799 | const char *p = strchr(types, c); |
11802 | if (p == NULL) | 11800 | if (p == NULL) |
11803 | break; | 11801 | break; |
11804 | subtype = p - types + VSNORMAL; | 11802 | subtype |= p - types + VSNORMAL; |
11805 | break; | 11803 | break; |
11806 | } | 11804 | } |
11807 | case '%': | 11805 | case '%': |
@@ -11831,12 +11829,11 @@ parsesub: { | |||
11831 | badsub: | 11829 | badsub: |
11832 | pungetc(); | 11830 | pungetc(); |
11833 | } | 11831 | } |
11834 | ((unsigned char *)stackblock())[typeloc] = subtype | flags; | 11832 | ((unsigned char *)stackblock())[typeloc] = subtype; |
11835 | if (subtype != VSNORMAL) { | 11833 | if (subtype != VSNORMAL) { |
11836 | varnest++; | 11834 | varnest++; |
11837 | if (dblquote) { | 11835 | if (dblquote) |
11838 | dqvarnest++; | 11836 | dqvarnest++; |
11839 | } | ||
11840 | } | 11837 | } |
11841 | STPUTC('=', out); | 11838 | STPUTC('=', out); |
11842 | } | 11839 | } |