You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by sf...@apache.org on 2013/08/03 19:35:21 UTC
svn commit: r1510044 - in /httpd/httpd/branches/2.2.x: ./ STATUS
server/util.c
Author: sf
Date: Sat Aug 3 17:35:21 2013
New Revision: 1510044
URL: http://svn.apache.org/r1510044
Log:
Merge r1485409:
Be more clever when allocating memory for log item to be escaped.
This should be faster and save about 70-100 bytes in the request pool with the default config.
Reviewed by: minfrin, rjung, rpluem
Modified:
httpd/httpd/branches/2.2.x/ (props changed)
httpd/httpd/branches/2.2.x/STATUS
httpd/httpd/branches/2.2.x/server/util.c
Propchange: httpd/httpd/branches/2.2.x/
------------------------------------------------------------------------------
Merged /httpd/httpd/trunk:r1485409
Modified: httpd/httpd/branches/2.2.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/STATUS?rev=1510044&r1=1510043&r2=1510044&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/STATUS (original)
+++ httpd/httpd/branches/2.2.x/STATUS Sat Aug 3 17:35:21 2013
@@ -97,19 +97,6 @@ RELEASE SHOWSTOPPERS:
PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
[ start all new proposals below, under PATCHES PROPOSED. ]
- * core: speed up (for common cases) and reduce memory usage of ap_escape_logitem
- This should save 70-100 bytes in the request pool for a default config.
- trunk patch: http://svn.apache.org/r1485409
- 2.4.x patch: http://svn.apache.org/r1485723
- 2.2.x patch: trunk works
- +1: minfrin, rjung, rpluem
- wrowe wonders why we copy and don't simply return the identity on no-change
- rjung: From an API point of view the function - as well as the html escape functions
- - takes a const char* and returns a plain char *. So a consumer would be free
- to write to the returned string. There's no such place in httpd code I can
- find but we can't rule it out for foreign modules. We could fix the signature
- (returning const char *) in trunk but not for 2.2 ad 2.4.
-
* mod_dav; Teeny patch to fix #55304
trunk: http://svn.apache.org/r1506714
+1: gstein, wrowe, rpluem
Modified: httpd/httpd/branches/2.2.x/server/util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/server/util.c?rev=1510044&r1=1510043&r2=1510044&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/server/util.c (original)
+++ httpd/httpd/branches/2.2.x/server/util.c Sat Aug 3 17:35:21 2013
@@ -1845,16 +1845,33 @@ AP_DECLARE(char *) ap_escape_logitem(apr
char *ret;
unsigned char *d;
const unsigned char *s;
+ apr_size_t length, escapes = 0;
if (!str) {
return NULL;
}
- ret = apr_palloc(p, 4 * strlen(str) + 1); /* Be safe */
+ /* Compute how many characters need to be escaped */
+ s = (const unsigned char *)str;
+ for (; *s; ++s) {
+ if (TEST_CHAR(*s, T_ESCAPE_LOGITEM)) {
+ escapes++;
+ }
+ }
+
+ /* Compute the length of the input string, including NULL */
+ length = s - (const unsigned char *)str + 1;
+
+ /* Fast path: nothing to escape */
+ if (escapes == 0) {
+ return apr_pmemdup(p, str, length);
+ }
+
+ /* Each escaped character needs up to 3 extra bytes (0 --> \x00) */
+ ret = apr_palloc(p, length + 3 * escapes);
d = (unsigned char *)ret;
s = (const unsigned char *)str;
for (; *s; ++s) {
-
if (TEST_CHAR(*s, T_ESCAPE_LOGITEM)) {
*d++ = '\\';
switch(*s) {