On Thu, 25 Aug 2011, [email protected] wrote:

Author: jim
Date: Thu Aug 25 17:38:19 2011
New Revision: 1161661

URL: http://svn.apache.org/viewvc?rev=1161661&view=rev
Log:
Merge in byteranges

Modified:
   httpd/httpd/trunk/modules/http/byterange_filter.c

Modified: httpd/httpd/trunk/modules/http/byterange_filter.c
URL: 
http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http/byterange_filter.c?rev=1161661&r1=1161660&r2=1161661&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http/byterange_filter.c (original)
+++ httpd/httpd/trunk/modules/http/byterange_filter.c Thu Aug 25 17:38:19 2011


+        if (in_merge) {
+            continue;
+        } else {
+            char *nr = apr_psprintf(r->pool, "%" APR_OFF_T_FMT "-%" 
APR_OFF_T_FMT,
+                                    ostart, oend);
+            merged = apr_pstrcat(r->pool, merged, (num_ranges++ ? "," : ""), 
nr, NULL);
+        }
    }

+    if (in_merge) {
+        char *nr = apr_psprintf(r->pool, "%" APR_OFF_T_FMT "-%" APR_OFF_T_FMT,
+                                ostart, oend);
+        merged = apr_pstrcat(r->pool, merged, (num_ranges++ ? "," : ""), nr, 
NULL);
+    }

Is it really a good idea to first parse the range string (involving lots of copying with ap_getword), then format it back into a string just to have it parsed by parse_byterange again? I would much prefer to have it parsed only once into an array of values and then do the merging in that array. This is more efficient and I think it would also lead to better readability. My original patch for merging/sorting had some code for that which we could reuse:

http://mail-archives.apache.org/mod_mbox/httpd-dev/201108.mbox/%[email protected]%3E

Reply via email to