summaryrefslogtreecommitdiff
path: root/network_io
diff options
context:
space:
mode:
authorBrian Pane <brianp@apache.org>2002-05-05 05:48:28 +0000
committerBrian Pane <brianp@apache.org>2002-05-05 05:48:28 +0000
commite31a841e9bee64e4f15390ef2ac89c645e64226e (patch)
tree9333926ba20833e747f45190140812e8a2d461d4 /network_io
parentf42023d676ccac122e56495777bd61f05d0ada36 (diff)
downloadapr-e31a841e9bee64e4f15390ef2ac89c645e64226e.tar.gz
Some performance fixes for inet_ntop6()
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@63358 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'network_io')
-rw-r--r--network_io/unix/inet_ntop.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/network_io/unix/inet_ntop.c b/network_io/unix/inet_ntop.c
index e9ad74720..59e9cac07 100644
--- a/network_io/unix/inet_ntop.c
+++ b/network_io/unix/inet_ntop.c
@@ -150,15 +150,23 @@ inet_ntop6(const unsigned char *src, char *dst, apr_size_t size)
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++) {