changeset 6797:40c2f3e06d23

Core: slight optimization in ngx_chain_update_chains(). It is not necessary to traverse *busy and link the *out when *out is NULL.
author hucongcong <hucong.c@foxmail.com>
date Thu, 10 Nov 2016 10:17:53 +0800
parents 92ad1c92bcf9
children 2decd6b34306
files src/core/ngx_buf.c
diffstat 1 files changed, 9 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/core/ngx_buf.c
+++ b/src/core/ngx_buf.c
@@ -186,17 +186,19 @@ ngx_chain_update_chains(ngx_pool_t *p, n
 {
     ngx_chain_t  *cl;
 
-    if (*busy == NULL) {
-        *busy = *out;
+    if (*out) {
+        if (*busy == NULL) {
+            *busy = *out;
 
-    } else {
-        for (cl = *busy; cl->next; cl = cl->next) { /* void */ }
+        } else {
+            for (cl = *busy; cl->next; cl = cl->next) { /* void */ }
 
-        cl->next = *out;
+            cl->next = *out;
+        }
+
+        *out = NULL;
     }
 
-    *out = NULL;
-
     while (*busy) {
         cl = *busy;