diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2007-10-04 22:20:38 +0800 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2007-10-04 22:20:38 +0800 |
commit | d4948c45d3e5f54823fac68f0c11f1dd09e75083 (patch) | |
tree | f83cbb5f1fc032dde5fd89e9780a79e69683e2b9 | |
parent | [PARSER] Fix parsing of ${##1} (diff) | |
download | dash-d4948c45d3e5f54823fac68f0c11f1dd09e75083.tar.gz dash-d4948c45d3e5f54823fac68f0c11f1dd09e75083.zip |
[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.
Diffstat (limited to '')
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | src/parser.c | 16 |
2 files changed, 8 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog index 3352429..940e4b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 2007-10-04 Herbert Xu <herbert@gondor.apana.org.au> * Fix parsing of ${##1}. + * Size optimisations in parameter expansion parser. 2007-10-04 Alexey Gladkov <legion@altlinux.org> diff --git a/src/parser.c b/src/parser.c index 9edb824..f49ee7d 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1142,7 +1142,6 @@ parseredir: { parsesub: { int subtype; int typeloc; - int flags; char *p; static const char types[] = "}-+?="; @@ -1163,18 +1162,18 @@ parsesub: { } else { USTPUTC(CTLVAR, out); typeloc = out - (char *)stackblock(); - USTPUTC(VSNORMAL, out); + STADJUST(1, out); subtype = VSNORMAL; - if (c == '{') { + if (likely(c == '{')) { c = pgetc(); subtype = 0; } varname: - if (c > PEOA && is_name(c)) { + if (is_name(c)) { do { STPUTC(c, out); c = pgetc(); - } while (c > PEOA && is_in_name(c)); + } while (is_in_name(c)); } else if (is_digit(c)) { do { STPUTC(c, out); @@ -1208,18 +1207,17 @@ varname: badsub: synerror("Bad substitution"); STPUTC('=', out); - flags = 0; if (subtype == 0) { switch (c) { case ':': - flags = VSNUL; + subtype = VSNUL; c = pgetc(); /*FALLTHROUGH*/ default: p = strchr(types, c); if (p == NULL) goto badsub; - subtype = p - types + VSNORMAL; + subtype |= p - types + VSNORMAL; break; case '%': case '#': @@ -1238,7 +1236,7 @@ badsub: synerror("Bad substitution"); } else { pungetc(); } - *((char *)stackblock() + typeloc) = subtype | flags; + *((char *)stackblock() + typeloc) = subtype; if (subtype != VSNORMAL) { varnest++; if (dblquote) |