[PATCH] round robin: optimize loop in ngx_http_upstream_init_round_robin()
Xiaochen Wang
wangxiaochen0 at gmail.com
Mon Oct 21 11:15:48 UTC 2013
# HG changeset patch
# User Xiaochen Wang <wangxiaochen0 at gmail.com>
# Date 1382350832 -28800
# Node ID b61b9d7d665fffd49fb6711db4d018a6aeb26222
# Parent fcecb9c6a0573f2edd48ff87cef69bd7e7523729
round robin: optimize loop in ngx_http_upstream_init_round_robin()
It is a trivial patch to move continue statement from inner loop to outer loop.
diff -r fcecb9c6a057 -r b61b9d7d665f src/http/ngx_http_upstream_round_robin.c
--- a/src/http/ngx_http_upstream_round_robin.c Fri Oct 18 18:13:49 2013 +0400
+++ b/src/http/ngx_http_upstream_round_robin.c Mon Oct 21 18:20:32 2013 +0800
@@ -71,11 +71,11 @@
n = 0;
for (i = 0; i < us->servers->nelts; i++) {
+ if (server[i].backup) {
+ continue;
+ }
+
for (j = 0; j < server[i].naddrs; j++) {
- if (server[i].backup) {
- continue;
- }
-
peers->peer[n].sockaddr = server[i].addrs[j].sockaddr;
peers->peer[n].socklen = server[i].addrs[j].socklen;
peers->peer[n].name = server[i].addrs[j].name;
@@ -125,11 +125,11 @@
n = 0;
for (i = 0; i < us->servers->nelts; i++) {
+ if (!server[i].backup) {
+ continue;
+ }
+
for (j = 0; j < server[i].naddrs; j++) {
- if (!server[i].backup) {
- continue;
- }
-
backup->peer[n].sockaddr = server[i].addrs[j].sockaddr;
backup->peer[n].socklen = server[i].addrs[j].socklen;
backup->peer[n].name = server[i].addrs[j].name;
More information about the nginx-devel
mailing list