]> git.kaiwu.me - nginx.git/commitdiff
Core: slight optimization in ngx_chain_update_chains().
authorhucongcong <hucong.c@foxmail.com>
Thu, 10 Nov 2016 02:17:53 +0000 (10:17 +0800)
committerhucongcong <hucong.c@foxmail.com>
Thu, 10 Nov 2016 02:17:53 +0000 (10:17 +0800)
It is not necessary to traverse *busy and link the *out when *out is NULL.

src/core/ngx_buf.c

index 00b6644585ab6a975a155f24a877f7168026db65..d30a0a4fcad679d05244811adb8813e6ff1ddefb 100644 (file)
@@ -186,16 +186,18 @@ ngx_chain_update_chains(ngx_pool_t *p, ngx_chain_t **free, ngx_chain_t **busy,
 {
     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;