summaryrefslogtreecommitdiff
path: root/networking/interface.c
diff options
context:
space:
mode:
authorDenys Vlasenko2009-10-23 13:03:59 +0200
committerDenys Vlasenko2009-10-23 13:03:59 +0200
commit56b3eec162c135d69e7b0bee70f30cf6ec31aae5 (patch)
tree03f73029b01cfa51e900a15f3ab5e12337ed5592 /networking/interface.c
parentf2cbb03a378aa48f2e08b64877d54da3fab4ea6a (diff)
downloadbusybox-56b3eec162c135d69e7b0bee70f30cf6ec31aae5.zip
busybox-56b3eec162c135d69e7b0bee70f30cf6ec31aae5.tar.gz
small optimizations of toupper/tolower
function old new delta in_ib 191 172 -19 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/interface.c')
-rw-r--r--networking/interface.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/networking/interface.c b/networking/interface.c
index fe6b23d..b64d24a 100644
--- a/networking/interface.c
+++ b/networking/interface.c
@@ -1242,10 +1242,8 @@ int FAST_FUNC in_ib(const char *bufp, struct sockaddr *sap)
c = *bufp++;
if (isdigit(c))
val = c - '0';
- else if (c >= 'a' && c <= 'f')
- val = c - 'a' + 10;
- else if (c >= 'A' && c <= 'F')
- val = c - 'A' + 10;
+ else if ((c|0x20) >= 'a' && (c|0x20) <= 'f')
+ val = (c|0x20) - ('a' - 10);
else {
errno = EINVAL;
return -1;
@@ -1254,17 +1252,15 @@ int FAST_FUNC in_ib(const char *bufp, struct sockaddr *sap)
c = *bufp;
if (isdigit(c))
val |= c - '0';
- else if (c >= 'a' && c <= 'f')
- val |= c - 'a' + 10;
- else if (c >= 'A' && c <= 'F')
- val |= c - 'A' + 10;
- else if (c == ':' || c == 0)
+ else if ((c|0x20) >= 'a' && (c|0x20) <= 'f')
+ val |= (c|0x20) - ('a' - 10);
+ else if (c == ':' || c == '\0')
val >>= 4;
else {
errno = EINVAL;
return -1;
}
- if (c != 0)
+ if (c != '\0')
bufp++;
*ptr++ = (unsigned char) (val & 0377);
i++;