diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-10-23 13:03:59 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-10-23 13:03:59 +0200 |
| commit | 56b3eec162c135d69e7b0bee70f30cf6ec31aae5 (patch) | |
| tree | 03f73029b01cfa51e900a15f3ab5e12337ed5592 | |
| parent | f2cbb03a378aa48f2e08b64877d54da3fab4ea6a (diff) | |
| download | busybox-w32-56b3eec162c135d69e7b0bee70f30cf6ec31aae5.tar.gz busybox-w32-56b3eec162c135d69e7b0bee70f30cf6ec31aae5.tar.bz2 busybox-w32-56b3eec162c135d69e7b0bee70f30cf6ec31aae5.zip | |
small optimizations of toupper/tolower
function old new delta
in_ib 191 172 -19
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| -rw-r--r-- | editors/awk.c | 13 | ||||
| -rw-r--r-- | networking/interface.c | 16 |
2 files changed, 11 insertions, 18 deletions
diff --git a/editors/awk.c b/editors/awk.c index 17244f9e6..bc1d93868 100644 --- a/editors/awk.c +++ b/editors/awk.c | |||
| @@ -2031,7 +2031,6 @@ static NOINLINE var *exec_builtin(node *op, var *res) | |||
| 2031 | { | 2031 | { |
| 2032 | #define tspl (G.exec_builtin__tspl) | 2032 | #define tspl (G.exec_builtin__tspl) |
| 2033 | 2033 | ||
| 2034 | int (*to_xxx)(int); | ||
| 2035 | var *tv; | 2034 | var *tv; |
| 2036 | node *an[4]; | 2035 | node *an[4]; |
| 2037 | var *av[4]; | 2036 | var *av[4]; |
| @@ -2061,7 +2060,8 @@ static NOINLINE var *exec_builtin(node *op, var *res) | |||
| 2061 | if ((uint32_t)nargs < (info >> 30)) | 2060 | if ((uint32_t)nargs < (info >> 30)) |
| 2062 | syntax_error(EMSG_TOO_FEW_ARGS); | 2061 | syntax_error(EMSG_TOO_FEW_ARGS); |
| 2063 | 2062 | ||
| 2064 | switch (info & OPNMASK) { | 2063 | info &= OPNMASK; |
| 2064 | switch (info) { | ||
| 2065 | 2065 | ||
| 2066 | case B_a2: | 2066 | case B_a2: |
| 2067 | #if ENABLE_FEATURE_AWK_LIBM | 2067 | #if ENABLE_FEATURE_AWK_LIBM |
| @@ -2126,15 +2126,12 @@ static NOINLINE var *exec_builtin(node *op, var *res) | |||
| 2126 | break; | 2126 | break; |
| 2127 | 2127 | ||
| 2128 | case B_lo: | 2128 | case B_lo: |
| 2129 | to_xxx = tolower; | ||
| 2130 | goto lo_cont; | ||
| 2131 | |||
| 2132 | case B_up: | 2129 | case B_up: |
| 2133 | to_xxx = toupper; | ||
| 2134 | lo_cont: | ||
| 2135 | s1 = s = xstrdup(as[0]); | 2130 | s1 = s = xstrdup(as[0]); |
| 2136 | while (*s1) { | 2131 | while (*s1) { |
| 2137 | *s1 = (*to_xxx)(*s1); | 2132 | //*s1 = (info == B_up) ? toupper(*s1) : tolower(*s1); |
| 2133 | if ((unsigned char)((*s1 | 0x20) - 'a') <= ('z' - 'a')) | ||
| 2134 | *s1 = (info == B_up) ? (*s1 & 0xdf) : (*s1 | 0x20); | ||
| 2138 | s1++; | 2135 | s1++; |
| 2139 | } | 2136 | } |
| 2140 | setvar_p(res, s); | 2137 | setvar_p(res, s); |
diff --git a/networking/interface.c b/networking/interface.c index fe6b23dbc..b64d24a58 100644 --- a/networking/interface.c +++ b/networking/interface.c | |||
| @@ -1242,10 +1242,8 @@ int FAST_FUNC in_ib(const char *bufp, struct sockaddr *sap) | |||
| 1242 | c = *bufp++; | 1242 | c = *bufp++; |
| 1243 | if (isdigit(c)) | 1243 | if (isdigit(c)) |
| 1244 | val = c - '0'; | 1244 | val = c - '0'; |
| 1245 | else if (c >= 'a' && c <= 'f') | 1245 | else if ((c|0x20) >= 'a' && (c|0x20) <= 'f') |
| 1246 | val = c - 'a' + 10; | 1246 | val = (c|0x20) - ('a' - 10); |
| 1247 | else if (c >= 'A' && c <= 'F') | ||
| 1248 | val = c - 'A' + 10; | ||
| 1249 | else { | 1247 | else { |
| 1250 | errno = EINVAL; | 1248 | errno = EINVAL; |
| 1251 | return -1; | 1249 | return -1; |
| @@ -1254,17 +1252,15 @@ int FAST_FUNC in_ib(const char *bufp, struct sockaddr *sap) | |||
| 1254 | c = *bufp; | 1252 | c = *bufp; |
| 1255 | if (isdigit(c)) | 1253 | if (isdigit(c)) |
| 1256 | val |= c - '0'; | 1254 | val |= c - '0'; |
| 1257 | else if (c >= 'a' && c <= 'f') | 1255 | else if ((c|0x20) >= 'a' && (c|0x20) <= 'f') |
| 1258 | val |= c - 'a' + 10; | 1256 | val |= (c|0x20) - ('a' - 10); |
| 1259 | else if (c >= 'A' && c <= 'F') | 1257 | else if (c == ':' || c == '\0') |
| 1260 | val |= c - 'A' + 10; | ||
| 1261 | else if (c == ':' || c == 0) | ||
| 1262 | val >>= 4; | 1258 | val >>= 4; |
| 1263 | else { | 1259 | else { |
| 1264 | errno = EINVAL; | 1260 | errno = EINVAL; |
| 1265 | return -1; | 1261 | return -1; |
| 1266 | } | 1262 | } |
| 1267 | if (c != 0) | 1263 | if (c != '\0') |
| 1268 | bufp++; | 1264 | bufp++; |
| 1269 | *ptr++ = (unsigned char) (val & 0377); | 1265 | *ptr++ = (unsigned char) (val & 0377); |
| 1270 | i++; | 1266 | i++; |
