small optimizations of toupper/tolower
function old new delta
in_ib 191 172 -19
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
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 @@
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 @@
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++;