* nis/nis_call.c (inetstr2int): Optimize.

This commit is contained in:
Ulrich Drepper 2005-12-09 06:48:51 +00:00
parent 8c058eec1e
commit 929b1c0708
2 changed files with 11 additions and 16 deletions

View File

@ -1,3 +1,7 @@
2005-12-08 Ulrich Drepper <drepper@redhat.com>
* nis/nis_call.c (inetstr2int): Optimize.
2005-12-08 Jakub Jelinek <jakub@redhat.com> 2005-12-08 Jakub Jelinek <jakub@redhat.com>
* nis/nis_call.c (__nisbind_create): Remove __nisbind_destroy, * nis/nis_call.c (__nisbind_create): Remove __nisbind_destroy,

View File

@ -40,25 +40,16 @@ extern u_short __pmap_getnisport (struct sockaddr_in *address, u_long program,
unsigned long unsigned long
inetstr2int (const char *str) inetstr2int (const char *str)
{ {
char buffer[strlen (str) + 3]; size_t j = 0;
size_t buflen; for (size_t i = 0; str[i] != '\0'; ++i)
size_t i, j; if (str[i] == '.' && ++j == 4)
buflen = stpcpy (buffer, str) - buffer;
j = 0;
for (i = 0; i < buflen; ++i)
if (buffer[i] == '.')
{ {
++j; char buffer[i + 1];
if (j == 4) buffer[i] = '\0';
{ return inet_addr (memcpy (buffer, str, i));
buffer[i] = '\0';
break;
}
} }
return inet_addr (buffer); return inet_addr (str);
} }
void void