diff options
author | Igor Sysoev <igor@sysoev.ru> | 2017-06-28 09:33:35 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2017-06-28 09:33:35 +0300 |
commit | 61c20aae4b2b2a142bb368219ed3a4b218d714a8 (patch) | |
tree | f741eaa5c8ad1ada83994629bd3124bf08e79cc9 | |
parent | 2006e9f537ba327d89e546188fbcf81307ce3551 (diff) | |
download | unit-61c20aae4b2b2a142bb368219ed3a4b218d714a8.tar.gz unit-61c20aae4b2b2a142bb368219ed3a4b218d714a8.tar.bz2 |
Small optimization in nxt_sockaddr_text().
-rw-r--r-- | src/nxt_sockaddr.c | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/src/nxt_sockaddr.c b/src/nxt_sockaddr.c index 4119fe8c..79d01b8a 100644 --- a/src/nxt_sockaddr.c +++ b/src/nxt_sockaddr.c @@ -193,17 +193,17 @@ nxt_sockaddr_text(nxt_sockaddr_t *sa) u_char *p, *start, *end, *octet; uint32_t port; + offset = offsetof(nxt_sockaddr_t, u) + sa->socklen; + sa->start = offset; + + start = nxt_pointer_to(sa, offset); end = nxt_pointer_to(sa, sa->sockaddr_size); switch (sa->u.sockaddr.sa_family) { case AF_INET: - offset = offsetof(nxt_sockaddr_t, u) + sizeof(struct sockaddr_in); - - sa->start = offset; sa->address_start = offset; - start = nxt_pointer_to(sa, offset); octet = (u_char *) &sa->u.sockaddr_in.sin_addr; p = nxt_sprintf(start, end, "%ud.%ud.%ud.%ud", @@ -219,14 +219,9 @@ nxt_sockaddr_text(nxt_sockaddr_t *sa) #if (NXT_INET6) case AF_INET6: - offset = offsetof(nxt_sockaddr_t, u) + sizeof(struct sockaddr_in6); - - sa->start = offset; sa->address_start = offset + 1; - start = nxt_pointer_to(sa, offset); p = start; - *p++ = '['; p = nxt_inet6_ntop(sa->u.sockaddr_in6.sin6_addr.s6_addr, p, end); @@ -245,12 +240,8 @@ nxt_sockaddr_text(nxt_sockaddr_t *sa) #if (NXT_HAVE_UNIX_DOMAIN) case AF_UNIX: - offset = offsetof(nxt_sockaddr_t, u) + sa->socklen; - - sa->start = offset; sa->address_start = offset; - start = nxt_pointer_to(sa, offset); p = (u_char *) sa->u.sockaddr_un.sun_path; #if (NXT_LINUX) |