changeset 4055:9cce506be97d

Ranges processing small optimization.
author Igor Sysoev <igor@sysoev.ru>
date Tue, 30 Aug 2011 12:45:24 +0000
parents 20c7c73d3efa
children e9213133993a
files src/http/modules/ngx_http_range_filter_module.c
diffstat 1 files changed, 17 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/src/http/modules/ngx_http_range_filter_module.c
+++ b/src/http/modules/ngx_http_range_filter_module.c
@@ -270,20 +270,8 @@ ngx_http_range_parse(ngx_http_request_t 
             while (*p == ' ') { p++; }
 
             if (*p == ',' || *p == '\0') {
-                range = ngx_array_push(&ctx->ranges);
-                if (range == NULL) {
-                    return NGX_ERROR;
-                }
-
-                range->start = start;
-                range->end = r->headers_out.content_length_n;
-                size += range->end - start;
-
-                if (*p++ != ',') {
-                    break;
-                }
-
-                continue;
+                end = r->headers_out.content_length_n;
+                goto found;
             }
 
         } else {
@@ -314,25 +302,28 @@ ngx_http_range_parse(ngx_http_request_t 
             return NGX_HTTP_RANGE_NOT_SATISFIABLE;
         }
 
+        if (end >= r->headers_out.content_length_n) {
+            /*
+             * Download Accelerator sends the last byte position
+             * that equals to the file length
+             */
+            end = r->headers_out.content_length_n;
+
+        } else {
+            end++;
+        }
+
+    found:
+
         range = ngx_array_push(&ctx->ranges);
         if (range == NULL) {
             return NGX_ERROR;
         }
 
         range->start = start;
+        range->end = end;
 
-        if (end >= r->headers_out.content_length_n) {
-            /*
-             * Download Accelerator sends the last byte position
-             * that equals to the file length
-             */
-            range->end = r->headers_out.content_length_n;
-
-        } else {
-            range->end = end + 1;
-        }
-
-        size += range->end - start;
+        size += end - start;
 
         if (*p++ != ',') {
             break;