You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ja...@apache.org on 2017/01/21 06:40:23 UTC

svn commit: r1779700 - /httpd/httpd/trunk/modules/filters/mod_brotli.c

Author: jailletc36
Date: Sat Jan 21 06:40:23 2017
New Revision: 1779700

URL: http://svn.apache.org/viewvc?rev=1779700&view=rev
Log:
Save a few bytes and a few cycles.

Modified:
    httpd/httpd/trunk/modules/filters/mod_brotli.c

Modified: httpd/httpd/trunk/modules/filters/mod_brotli.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/filters/mod_brotli.c?rev=1779700&r1=1779699&r2=1779700&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/filters/mod_brotli.c (original)
+++ httpd/httpd/trunk/modules/filters/mod_brotli.c Sat Jan 21 06:40:23 2017
@@ -443,9 +443,9 @@ static apr_status_t compress_filter(ap_f
                 apr_size_t len = strlen(etag);
 
                 if (len > 2 && etag[len - 1] == '"') {
-                    etag = apr_pstrndup(r->pool, etag, len - 1);
+                    etag = apr_pstrmemdup(r->pool, etag, len - 1);
                     etag = apr_pstrcat(r->pool, etag, "-br\"", NULL);
-                    apr_table_set(r->headers_out, "ETag", etag);
+                    apr_table_setn(r->headers_out, "ETag", etag);
                 }
             }
         }



Re: svn commit: r1779700 - /httpd/httpd/trunk/modules/filters/mod_brotli.c

Posted by Ruediger Pluem <rp...@apache.org>.

On 01/21/2017 09:57 AM, Yann Ylavic wrote:
> Hi,
> 
> On Sat, Jan 21, 2017 at 7:40 AM,  <ja...@apache.org> wrote:
>> Author: jailletc36
>> Date: Sat Jan 21 06:40:23 2017
>> New Revision: 1779700
>>
>> URL: http://svn.apache.org/viewvc?rev=1779700&view=rev
>> Log:
>> Save a few bytes and a few cycles.
>>
>> Modified:
>>     httpd/httpd/trunk/modules/filters/mod_brotli.c
>>
>> Modified: httpd/httpd/trunk/modules/filters/mod_brotli.c
>> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/filters/mod_brotli.c?rev=1779700&r1=1779699&r2=1779700&view=diff
>> ==============================================================================
>> --- httpd/httpd/trunk/modules/filters/mod_brotli.c (original)
>> +++ httpd/httpd/trunk/modules/filters/mod_brotli.c Sat Jan 21 06:40:23 2017
>> @@ -443,9 +443,9 @@ static apr_status_t compress_filter(ap_f
>>                  apr_size_t len = strlen(etag);
>>
>>                  if (len > 2 && etag[len - 1] == '"') {
>> -                    etag = apr_pstrndup(r->pool, etag, len - 1);
>> +                    etag = apr_pstrmemdup(r->pool, etag, len - 1);
>>                      etag = apr_pstrcat(r->pool, etag, "-br\"", NULL);
> 
> We could possibly save more bytes yet with something like:
>                        etag = apr_psnprintf(r->pool, etag, "%.*s-br\"",
>                                             (int)(len - 1), etag);

Saves bytes, but costs cycles as apr_psnprintf requires much more cycles than the above.
So IMHO I would stick with the above.

Regards

R�diger


Re: svn commit: r1779700 - /httpd/httpd/trunk/modules/filters/mod_brotli.c

Posted by Yann Ylavic <yl...@gmail.com>.
Hi,

On Sat, Jan 21, 2017 at 7:40 AM,  <ja...@apache.org> wrote:
> Author: jailletc36
> Date: Sat Jan 21 06:40:23 2017
> New Revision: 1779700
>
> URL: http://svn.apache.org/viewvc?rev=1779700&view=rev
> Log:
> Save a few bytes and a few cycles.
>
> Modified:
>     httpd/httpd/trunk/modules/filters/mod_brotli.c
>
> Modified: httpd/httpd/trunk/modules/filters/mod_brotli.c
> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/filters/mod_brotli.c?rev=1779700&r1=1779699&r2=1779700&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/modules/filters/mod_brotli.c (original)
> +++ httpd/httpd/trunk/modules/filters/mod_brotli.c Sat Jan 21 06:40:23 2017
> @@ -443,9 +443,9 @@ static apr_status_t compress_filter(ap_f
>                  apr_size_t len = strlen(etag);
>
>                  if (len > 2 && etag[len - 1] == '"') {
> -                    etag = apr_pstrndup(r->pool, etag, len - 1);
> +                    etag = apr_pstrmemdup(r->pool, etag, len - 1);
>                      etag = apr_pstrcat(r->pool, etag, "-br\"", NULL);

We could possibly save more bytes yet with something like:
                       etag = apr_psnprintf(r->pool, etag, "%.*s-br\"",
                                            (int)(len - 1), etag);

Regards,
Yann.