brianp 02/05/04 23:19:42
Modified: network_io/unix inet_ntop.c
Log:
inet_ntop6() optimization: collapse two passes through the input
address into one
Revision Changes Path
1.16 +9 -6 apr/network_io/unix/inet_ntop.c
Index: inet_ntop.c
===================================================================
RCS file: /home/cvs/apr/network_io/unix/inet_ntop.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- inet_ntop.c 5 May 2002 05:54:51 -0000 1.15
+++ inet_ntop.c 5 May 2002 06:19:42 -0000 1.16
@@ -161,16 +161,16 @@
next_src = src;
src_end = src + IN6ADDRSZ;
next_dest = words;
+ best.base = -1;
+ cur.base = -1;
+ i = 0;
do {
unsigned int next_word = (unsigned int)*next_src++;
next_word <<= 8;
next_word |= (unsigned int)*next_src++;
*next_dest++ = next_word;
- } while (next_src < src_end);
- best.base = -1;
- cur.base = -1;
- for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) {
- if (words[i] == 0) {
+
+ if (next_word == 0) {
if (cur.base == -1) {
cur.base = i;
cur.len = 1;
@@ -186,7 +186,10 @@
cur.base = -1;
}
}
- }
+
+ i++;
+ } while (next_src < src_end);
+
if (cur.base != -1) {
if (best.base == -1 || cur.len > best.len) {
best = cur;