From: Ulrich Drepper Date: Fri, 9 Dec 2005 06:48:51 +0000 (+0000) Subject: * nis/nis_call.c (inetstr2int): Optimize. X-Git-Tag: cvs/fedora-glibc-20051219T1003~37 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=929b1c07081afacabd347728609b1522f9ddb0a4;p=platform%2Fupstream%2Fglibc.git * nis/nis_call.c (inetstr2int): Optimize. --- diff --git a/ChangeLog b/ChangeLog index 7bfbb30..81be683 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2005-12-08 Ulrich Drepper + + * nis/nis_call.c (inetstr2int): Optimize. + 2005-12-08 Jakub Jelinek * nis/nis_call.c (__nisbind_create): Remove __nisbind_destroy, diff --git a/nis/nis_call.c b/nis/nis_call.c index 07f95f0..5b432b7 100644 --- a/nis/nis_call.c +++ b/nis/nis_call.c @@ -40,25 +40,16 @@ extern u_short __pmap_getnisport (struct sockaddr_in *address, u_long program, unsigned long inetstr2int (const char *str) { - char buffer[strlen (str) + 3]; - size_t buflen; - size_t i, j; - - buflen = stpcpy (buffer, str) - buffer; - - j = 0; - for (i = 0; i < buflen; ++i) - if (buffer[i] == '.') + size_t j = 0; + for (size_t i = 0; str[i] != '\0'; ++i) + if (str[i] == '.' && ++j == 4) { - ++j; - if (j == 4) - { - buffer[i] = '\0'; - break; - } + char buffer[i + 1]; + buffer[i] = '\0'; + return inet_addr (memcpy (buffer, str, i)); } - return inet_addr (buffer); + return inet_addr (str); } void