httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwool...@apache.org
Subject cvs commit: httpd-2.0/modules/http http_protocol.c
Date Sun, 08 Jul 2001 06:24:56 GMT
jwoolley    01/07/07 23:24:56

  Modified:    modules/http http_protocol.c
  Log:
  Avoid redundant strlen() calls by using apr_brigade_write() instead of
  apr_brigade_puts().  There is still some redundancy--it'd be ideal if there
  were an apr_pstrcat() variant that returned the length of the string since
  it computes it (twice) anyway so we didn't have to do it yet again.  Until
  such a beast exists, computing the length three times is better than four.
  :-/
  
  Revision  Changes    Path
  1.328     +15 -8     httpd-2.0/modules/http/http_protocol.c
  
  Index: http_protocol.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/http/http_protocol.c,v
  retrieving revision 1.327
  retrieving revision 1.328
  diff -u -d -u -r1.327 -r1.328
  --- http_protocol.c	2001/07/07 16:20:45	1.327
  +++ http_protocol.c	2001/07/08 06:24:55	1.328
  @@ -782,10 +782,12 @@
                                const char *fieldname, const char *fieldval)
   {
       char *headfield;
  +    apr_size_t len;
   
       headfield = apr_pstrcat(h->pool, fieldname, ": ", fieldval, CRLF, NULL);
  -    ap_xlate_proto_to_ascii(headfield, strlen(headfield));
  -    apr_brigade_puts(h->bb, NULL, NULL, headfield);
  +    len = strlen(headfield);
  +    ap_xlate_proto_to_ascii(headfield, len);
  +    apr_brigade_write(h->bb, NULL, NULL, headfield, len);
       return 1;
   }
   
  @@ -826,6 +828,7 @@
       char *date = NULL;
       char *tmp;
       header_struct h;
  +    apr_size_t len;
   
       if (r->assbackwards) {
           /* there are no headers to send */
  @@ -835,8 +838,9 @@
       /* Output the HTTP/1.x Status-Line and the Date and Server fields */
   
       tmp = apr_pstrcat(r->pool, protocol, " ", r->status_line, CRLF, NULL);
  -    ap_xlate_proto_to_ascii(tmp, strlen(tmp));
  -    apr_brigade_puts(bb, NULL, NULL, tmp);
  +    len = strlen(tmp);
  +    ap_xlate_proto_to_ascii(tmp, len);
  +    apr_brigade_write(bb, NULL, NULL, tmp, len);
   
       date = apr_palloc(r->pool, APR_RFC822_DATE_LEN);
       apr_rfc822_date(date, r->request_time);
  @@ -880,15 +884,18 @@
       char tmp[] = "X-Pad: avoid browser bug" CRLF;
       char crlf[] = CRLF;
       apr_ssize_t len;
  +    apr_size_t buflen;
   
       (void) apr_brigade_length(bb, 1, &len);
   
       if (len >= 255 && len <= 257) {
  -        ap_xlate_proto_to_ascii(tmp, strlen(tmp));
  -        apr_brigade_puts(bb, NULL, NULL, tmp);
  +        buflen = strlen(tmp);
  +        ap_xlate_proto_to_ascii(tmp, buflen);
  +        apr_brigade_write(bb, NULL, NULL, tmp, buflen);
       }
  -    ap_xlate_proto_to_ascii(crlf, strlen(crlf));
  -    apr_brigade_puts(bb, NULL, NULL, crlf);
  +    buflen = strlen(crlf);
  +    ap_xlate_proto_to_ascii(crlf, buflen);
  +    apr_brigade_write(bb, NULL, NULL, crlf, buflen);
   }
   
   /* Build the Allow field-value from the request handler method mask.
  
  
  

Mime
View raw message