brianp 02/05/04 22:48:28
Modified: network_io/unix inet_ntop.c
Log:
Some performance fixes for inet_ntop6()
Revision Changes Path
1.14 +11 -3 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.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- inet_ntop.c 12 Feb 2002 21:57:12 -0000 1.13
+++ inet_ntop.c 5 May 2002 05:48:28 -0000 1.14
@@ -150,15 +150,23 @@
struct { int base, len; } best, cur;
unsigned int words[IN6ADDRSZ / INT16SZ];
int i;
+ const unsigned char *next_src, *src_end;
+ unsigned int *next_dest;
/*
* Preprocess:
* Copy the input (bytewise) array into a wordwise array.
* Find the longest run of 0x00's in src[] for :: shorthanding.
*/
- memset(words, '\0', sizeof words);
- for (i = 0; i < IN6ADDRSZ; i++)
- words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
+ next_src = src;
+ src_end = src + IN6ADDRSZ;
+ next_dest = words;
+ 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++) {